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

MeterGroup

원문 보기 위키 갱신

알려진 범위 안의 스칼라 측정값을 표시하는 컴포넌트예요. 여러 개의 측정값을 하나의 바에 쌓아 보여줄 수 있어요.

출처: 문서

본문

설치 (Installation)

Shadcn CLI Manual ```bash npx shadcn@latest add https://primereact.dev/r/metergroup.json ``` 다음 코드를 프로젝트에 복사해서 붙여넣으세요. import 경로를 프로젝트 설정에 맞게 수정하세요.

사용법 (Usage)

import { MeterGroup, MeterGroupMeters, MeterGroupMeter, MeterGroupLabels, MeterGroupLabel, MeterGroupMarker, MeterGroupText } from '@/components/ui/metergroup';
<MeterGroup aria-valuenow={total}>
    <MeterGroupMeters>
        <MeterGroupMeter />
    </MeterGroupMeters>
    <MeterGroupLabels>
        <MeterGroupLabel>
            <MeterGroupMarker />
            <MeterGroupText></MeterGroupText>
        </MeterGroupLabel>
    </MeterGroupLabels>
</MeterGroup>

MeterGroup는 미터 값들을 스스로 합산하지 않아요. 총합을 직접 계산해 접근성을 위해 aria-valuenow로 전달해야 해요. 자식에는 index prop이 없으니 CSS에서 :nth-child(n)을 사용해 개별 행을 타깃하세요.

예시 (Examples)

기본 (Basic)

다중 (Multiple)

각 MeterGroupMeter는 value와 선택적인 color를 받아요. 미터를 더 추가하면 하나의 바에 쌓여요.

색상 (Color)

color는 CSS 색상 값, 디자인 토큰(var(--p-violet-500)), hex, rgb, hsl 또는 이름 있는 색상을 받아요. 이 값은 요소의 --p-metergroup-color CSS 변수에 기록돼요. className이나 style로 직접 스타일링할 수도 있어요.

아이콘 (Icon)

아이콘 파트는 따로 없어요. MeterGroupLabel 안의 마커 옆에 직접 <i>나 SVG를 넣으면 돼요.

라벨 (Label)

라벨은 기본적으로 가로로 렌더링돼요. MeterGroupLabels에 orientation="vertical"을 설정하면 세로로 쌓아요.

세로 (Vertical)

MeterGroup은 orientation="horizontal"(기본값) 또는 orientation="vertical"을 받아요.

최소-최대 (Min-Max)

min과 max로 범위를 설정해요. 기본값은 0과 100이에요.

템플릿 (Template)

MeterGroup은 라벨, 미터 항목, 미터 주변 콘텐츠에 대한 템플릿 지원을 제공해요.

하위 컴포넌트 (Sub-Components)

MeterGroupRoot, MeterGroupMeters, MeterGroupMeter, MeterGroupLabels, MeterGroupLabel, MeterGroupMarker, MeterGroupText 컴포넌트 문서는 Primitive API에서 확인하세요.

훅 (Hooks)

useMeterGroup 훅 문서는 Headless API에서 확인하세요.

접근성 (Accessibility)

WAI-ARIA 준수 세부 사항과 키보드 지원은 MeterGroup Primitive에서 확인하세요.

더 알아보기 (Learn more)