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

미터 (Meter)

원문 보기 위키 갱신

Meter는 알려진 범위 내의 수량 또는 분수 값을 나타내는 컴포넌트예요.

출처: HeroUI Meter

본문

사용 방법 (Usage)

import { Meter, Label } from '@heroui/react';
{
  "preview": "meter-basic"
}

구조 (Anatomy)

import { Meter, Label } from '@heroui/react';

export default () => (
  <Meter value={60}>
    <Label>Storage</Label>
    <Meter.Output />
    <Meter.Track>
      <Meter.Fill />
    </Meter.Track>
  </Meter>
);

예제 (Examples)

크기 (Sizes)

{
  "preview": "meter-sizes"
}

색상 (Colors)

{
  "preview": "meter-colors"
}

라벨 없이 (Without Label)

표시되는 라벨이 필요하지 않을 때는 접근성을 위해 aria-label을 사용해요.

{
  "preview": "meter-without-label"
}

사용자 지정 값 범위 (Custom Value Scale)

값 범위와 표시 형식을 커스터마이징하려면 minValue, maxValue, formatOptions를 사용해요.

{
  "preview": "meter-custom-value"
}

커스터마이징 (Customization)

Tailwind CSS

{
  "preview": "meter-custom-styles"
}

글로벌 CSS (Global CSS)

Meter 컴포넌트 클래스를 커스터마이징하려면 @layer components 지시문을 사용할 수 있어요. 더 알아보기.

@layer components {
  .meter {
    @apply w-full gap-2;
  }

  .meter__track {
    @apply h-3 rounded-full;
  }

  .meter__fill {
    @apply rounded-full;
  }
}

스타일 참조 (Styling Reference)

HeroUI는 컴포넌트 변형과 상태를 재사용하고 커스터마이징하기 쉽도록 BEM 방법론을 따르고 있어요.

CSS 클래스 (CSS Classes)

Meter 컴포넌트는 다음 CSS 클래스를 사용해요 (소스 스타일 보기):

기본 및 요소 클래스 (Base & Element Classes)

  • .meter - 기본 컨테이너 (그리드 레이아웃)
  • .meter__output - 값 텍스트 표시
  • .meter__track - 트랙 배경
  • .meter__fill - 트랙의 채워진 부분

크기 클래스 (Size Classes)

  • .meter--sm - 작은 크기 변형 (더 얇은 트랙)
  • .meter--md - 중간 크기 변형 (기본값)
  • .meter--lg - 큰 크기 변형 (더 두꺼운 트랙)

색상 클래스 (Color Classes)

  • .meter--default - 기본 색상 변형
  • .meter--accent - 액센트 색상 변형
  • .meter--success - 성공 색상 변형
  • .meter--warning - 경고 색상 변형
  • .meter--danger - 위험 색상 변형

API 참조 (API Reference)

Meter

React Aria Meter를 상속해요.

Prop Type Default Description
value number 0 The current value
minValue number 0 The minimum value
maxValue number 100 The maximum value
size "sm" | "md" | "lg" "md" Size of the meter track
color "default" | "accent" | "success" | "warning" | "danger" "accent" Color of the fill bar
formatOptions Intl.NumberFormatOptions {style: 'percent'} Number format for the value display
valueLabel ReactNode - Custom value label content
children ReactNode | (values: MeterRenderProps) => ReactNode - Content or render prop

렌더 props (Render Props)

렌더 prop 패턴을 사용할 때 다음 값이 제공돼요:

Prop Type Description
percentage number The percentage of the meter (0-100)
valueText string The formatted value text

더 알아보기 (Learn more)

HeroUI Meter에 대해 더 알아보려면 공식 문서를 확인해 주세요.