본문으로 바로가기 본문 바로가기
WIKI 기술 지식 베이스

진행률

원문 보기 위키 갱신

진행률 (Progress)

작업의 진행 상태를 표시하는 인디케이터 컴포넌트예요. v-model로 값을 제어하고, 최댓값, 상태 표시, 불확정 상태, 방향·애니메이션 등을 지원합니다.

출처: Nuxt UI

본문

v-model 디렉티브를 사용해 Progress의 값을 제어해요.

<script setup lang="ts">
const value = ref(50)
</script>

<template>
  <UProgress v-model="value" />
</template>

[!NOTE]

여러 세그먼트로 나뉘어 합산되는 단일 바를 만들려면 ProgressGroup 컴포넌트를 사용해 주세요.

최댓값 (Max)

max prop을 사용해 Progress의 최댓값을 설정해요.

<script setup lang="ts">
const value = ref(3)
</script>

<template>
  <UProgress v-model="value" :max="4" />
</template>

max prop에 문자열 배열을 사용하면 바 아래에 현재 단계를 표시하고, Progress의 최댓값은 배열의 길이가 돼요.

<script setup lang="ts">
const value = ref(3)
</script>

<template>
  <UProgress v-model="value" :max="[
  'Waiting...',
  'Cloning...',
  'Migrating...',
  'Deploying...',
  'Done!'
]" />
</template>

상태 (Status)

status prop을 사용해 바 위에 현재 Progress 값을 표시해요.

<script setup lang="ts">
const value = ref(50)
</script>

<template>
  <UProgress v-model="value" status />
</template>

[!TIP]

status는 바의 끝을 따라가요. 전체 너비로 늘리려면 :ui="{ status: 'w-full' }"를 사용하세요.

불확정 (Indeterminate)

v-model이 설정되지 않았거나 값이 null이면 Progress는 불확정(indeterminate) 상태가 돼요. 진행 바는 carousel로 애니메이션되며, animation prop으로 변경할 수 있습니다.

<script setup lang="ts">
const value = ref(null)
</script>

<template>
  <UProgress />
</template>

애니메이션 (Animation)

animation prop을 사용해 Progress의 애니메이션을 역방향 캐러셀, 스윙 바, 또는 탄성(elastic) 바로 바꿔요. 기본값은 carousel입니다.

<template>
  <UProgress animation="swing" />
</template>

[!TIP]

사용자가 축소 모션을 선호하면 애니메이션이 자동으로 비활성화되고, 불확정 바가 전체 너비 펄스로 표시됩니다.

방향 (Orientation)

orientation prop을 사용해 Progress의 방향을 바꿔요. 기본값은 horizontal입니다.

<template>
  <UProgress orientation="vertical" class="h-48" />
</template>

색상 (Color)

color prop을 사용해 Progress의 색상을 바꿔요.

<template>
  <UProgress color="neutral" />
</template>

[!TIP]

이 prop은 테마 밖의 팔레트를 위해 모든 CSS 색상 값도 받아들여요.

크기 (Size)

size prop을 사용해 Progress의 크기를 바꿔요.

<template>
  <UProgress size="xl" />
</template>

반전 (Inverted)

inverted prop을 사용해 Progress를 시각적으로 반전시켜요.

<template>
  <UProgress inverted v-model="value" />
</template>

API

Props

/**
 * Props for the Progress component
 */
interface ProgressProps {
  /**
   * The element or component this component should render as.
   * @default 'div'
   */
  as?: any;
  /**
   * The maximum progress value.
   */
  max?: number | any[] | undefined;
  /**
   * Display the current progress value.
   */
  status?: boolean | undefined;
  /**
   * Whether the progress is visually inverted.
   * @default false
   */
  inverted?: boolean | undefined;
  /**
   * @default 'md'
   */
  size?: "2xs" | "xs" | "sm" | "md" | "lg" | "xl" | "2xl" | undefined;
  /**
   * Any theme color, or any CSS color value for palettes outside the theme.
   * @default 'primary'
   */
  color?: "error" | "primary" | "secondary" | "success" | "info" | "warning" | "neutral" | string & {} | undefined;
  /**
   * The orientation of the progress bar.
   * @default 'horizontal'
   */
  orientation?: "horizontal" | "vertical" | undefined;
  /**
   * The animation of the progress bar.
   * @default 'carousel'
   */
  animation?: "carousel" | "carousel-inverse" | "swing" | "elastic" | undefined;
  ui?: { root?: SlotClass; base?: SlotClass; indicator?: SlotClass; status?: SlotClass; steps?: SlotClass; step?: SlotClass; } | undefined;
  /**
   * A function to get the accessible label text in a human-readable format.
   * 
   *  If not provided, the value label will be read as the numeric value as a percentage of the max value.
   */
  getValueLabel?: (value: number | null | undefined, max: number): string | undefined | undefined;
  /**
   * A function to get the accessible value text representing the current value in a human-readable format.
   */
  getValueText?: (value: number | null | undefined, max: number): string | undefined | undefined;
  /**
   * The progress value. Can be bind as `v-model`.
   * @default null
   */
  modelValue?: null | number | undefined;
}

Slots

/**
 * Slots for the Progress component
 */
interface ProgressSlots {
  status(): any;
}

Emits

/**
 * Emitted events for the Progress component
 */
interface ProgressEmits {
  update:modelValue: (payload: [value: string[] | undefined]) => void;
  update:max: (payload: [value: number]) => void;
}

테마 (Theme)

export default defineAppConfig({
  ui: {
    progress: {
      slots: {
        root: 'gap-2',
        base: 'relative overflow-hidden rounded-full bg-accented',
        indicator: 'rounded-full size-full transition-transform duration-200 ease-out motion-reduce:transition-none motion-reduce:data-[state=indeterminate]:animate-pulse',
        status: 'flex text-dimmed duration-200 ease-out motion-reduce:transition-none',
        steps: 'grid items-end',
        step: 'truncate text-end row-start-1 col-start-1 transition-opacity ease-out'
      },
      variants: {
        animation: {
          carousel: '',
          'carousel-inverse': '',
          swing: '',
          elastic: ''
        },
        color: {
          primary: {
            indicator: 'bg-primary',
            steps: 'text-primary'
          },
          secondary: {
            indicator: 'bg-secondary',
            steps: 'text-secondary'
          },
          success: {
            indicator: 'bg-success',
            steps: 'text-success'
          },
          info: {
            indicator: 'bg-info',
            steps: 'text-info'
          },
          warning: {
            indicator: 'bg-warning',
            steps: 'text-warning'
          },
          error: {
            indicator: 'bg-error',
            steps: 'text-error'
          },
          neutral: {
            indicator: 'bg-inverted',
            steps: 'text-highlighted'
          }
        },
        size: {
          '2xs': {
            status: 'text-xs',
            steps: 'text-xs'
          },
          xs: {
            status: 'text-xs',
            steps: 'text-xs'
          },
          sm: {
            status: 'text-sm',
            steps: 'text-sm'
          },
          md: {
            status: 'text-sm',
            steps: 'text-sm'
          },
          lg: {
            status: 'text-sm',
            steps: 'text-sm'
          },
          xl: {
            status: 'text-base',
            steps: 'text-base'
          },
          '2xl': {
            status: 'text-base',
            steps: 'text-base'
          }
        },
        step: {
          active: {
            step: 'opacity-100'
          },
          first: {
            step: 'opacity-100 text-muted'
          },
          other: {
            step: 'opacity-0'
          },
          last: {
            step: ''
          }
        },
        orientation: {
          horizontal: {
            root: 'w-full flex flex-col',
            base: 'w-full',
            status: 'flex-row items-center justify-end w-(--percent) min-w-fit transition-[width]'
          },
          vertical: {
            root: 'h-full flex flex-row-reverse',
            base: 'h-full',
            status: 'flex-col justify-end h-(--percent) min-h-fit transition-[height]'
          }
        },
        inverted: {
          true: {
            status: 'self-end'
          }
        }
      },
      compoundVariants: [
        {
          inverted: true,
          orientation: 'horizontal',
          class: {
            step: 'text-start',
            status: 'flex-row-reverse'
          }
        },
        {
          inverted: true,
          orientation: 'vertical',
          class: {
            steps: 'items-start',
            status: 'flex-col-reverse'
          }
        },
        {
          orientation: 'horizontal',
          size: '2xs',
          class: 'h-px'
        },
        {
          orientation: 'horizontal',
          size: 'xs',
          class: 'h-0.5'
        },
        {
          orientation: 'horizontal',
          size: 'sm',
          class: 'h-1'
        },
        {
          orientation: 'horizontal',
          size: 'md',
          class: 'h-2'
        },
        {
          orientation: 'horizontal',
          size: 'lg',
          class: 'h-3'
        },
        {
          orientation: 'horizontal',
          size: 'xl',
          class: 'h-4'
        },
        {
          orientation: 'horizontal',
          size: '2xl',
          class: 'h-5'
        },
        {
          orientation: 'vertical',
          size: '2xs',
          class: 'w-px'
        },
        {
          orientation: 'vertical',
          size: 'xs',
          class: 'w-0.5'
        },
        {
          orientation: 'vertical',
          size: 'sm',
          class: 'w-1'
        },
        {
          orientation: 'vertical',
          size: 'md',
          class: 'w-2'
        },
        {
          orientation: 'vertical',
          size: 'lg',
          class: 'w-3'
        },
        {
          orientation: 'vertical',
          size: 'xl',
          class: 'w-4'
        },
        {
          orientation: 'vertical',
          size: '2xl',
          class: 'w-5'
        },
        {
          orientation: 'horizontal',
          animation: 'carousel',
          class: {
            indicator: 'motion-safe:data-[state=indeterminate]:animate-[carousel_2s_linear_infinite] motion-safe:data-[state=indeterminate]:rtl:animate-[carousel-rtl_2s_linear_infinite]'
          }
        },
        {
          orientation: 'vertical',
          animation: 'carousel',
          class: {
            indicator: 'motion-safe:data-[state=indeterminate]:animate-[carousel-vertical_2s_linear_infinite]'
          }
        },
        {
          orientation: 'horizontal',
          animation: 'carousel-inverse',
          class: {
            indicator: 'motion-safe:data-[state=indeterminate]:animate-[carousel-inverse_2s_linear_infinite] motion-safe:data-[state=indeterminate]:rtl:animate-[carousel-inverse-rtl_2s_linear_infinite]'
          }
        },
        {
          orientation: 'vertical',
          animation: 'carousel-inverse',
          class: {
            indicator: 'motion-safe:data-[state=indeterminate]:animate-[carousel-inverse-vertical_2s_linear_infinite]'
          }
        },
        {
          orientation: 'horizontal',
          animation: 'swing',
          class: {
            indicator: 'motion-safe:data-[state=indeterminate]:animate-[swing_2s_var(--ease-in-out)_infinite]'
          }
        },
        {
          orientation: 'vertical',
          animation: 'swing',
          class: {
            indicator: 'motion-safe:data-[state=indeterminate]:animate-[swing-vertical_2s_var(--ease-in-out)_infinite]'
          }
        },
        {
          orientation: 'horizontal',
          animation: 'elastic',
          class: {
            indicator: 'relative motion-safe:data-[state=indeterminate]:animate-[elastic_2s_var(--ease-in-out)_infinite]'
          }
        },
        {
          orientation: 'vertical',
          animation: 'elastic',
          class: {
            indicator: 'relative motion-safe:data-[state=indeterminate]:animate-[elastic-vertical_2s_var(--ease-in-out)_infinite]'
          }
        }
      ],
      defaultVariants: {
        animation: 'carousel',
        color: 'primary',
        size: 'md'
      }
    }
  }
})

변경 기록 (Changelog)

컴포넌트와 테마의 커밋 내역을 확인해 보세요.

더 알아보기 (Learn more)