MeterGroup (미터 그룹)
MeterGroup은 알려진 범위 안에서 스칼라 측정값을 표시해요.
출처: 문서
본문
가져오기 (Import)
import MeterGroup from 'primevue/metergroup';
접근성 (Accessibility)
스크린 리더 — MeterGroup 컴포넌트는 meter 역할을 사용하고, 여기에 aria-valuemin, aria-valuemax, aria-valuenow 속성이 더해져요. 컴포넌트를 설명하는 값은 aria-labelledby 프롭으로 정의할 수 있어요. 키보드 지원 — 이 컴포넌트는 상호작용 요소를 포함하지 않아요.
기본 (Basic)
MeterGroup은 표시할 데이터로 value를 필요로 하고, 컬렉션의 각 항목은 MeterItem 타입이어야 해요.
<MeterGroup :value="value" />
아이콘 (Icon)
기본 마커 대신 라벨 옆에 아이콘을 표시할 수 있어요.
<MeterGroup :value="value" />
Composition API Example
<template>
<div class="card">
<MeterGroup :value="value" />
</div>
</template>
<script setup>
import { ref } from "vue";
const value = ref([
{ label: 'Apps', color: '#34d399', value: 16, icon: 'pi pi-table' },
{ label: 'Messages', color: '#fbbf24', value: 8, icon: 'pi pi-inbox' },
{ label: 'Media', color: '#60a5fa', value: 24, icon: 'pi pi-image' },
{ label: 'System', color: '#c084fc', value: 10, icon: 'pi pi-cog' }
]);
<\/script>
라벨 (Label)
미터를 기준으로 한 라벨의 위치는 labelPosition 속성으로 정의해요. 라벨의 기본 방향은 가로이고, labelOrientation 옵션으로 세로 방향도 쓸 수 있어요.
<MeterGroup :value="value" labelPosition="start" labelOrientation="vertical" />
Composition API Example
<template>
<div class="card">
<MeterGroup :value="value" labelPosition="start" labelOrientation="vertical" />
</div>
</template>
<script setup>
import { ref } from "vue";
const value = ref([
{ label: 'Apps', color: '#34d399', value: 16 },
{ label: 'Messages', color: '#fbbf24', value: 8 },
{ label: 'Media', color: '#60a5fa', value: 24 },
{ label: 'System', color: '#c084fc', value: 10 }
]);
<\/script>
최소/최대 (Min-Max)
경계는 min과 max 값으로 설정하며, 기본값은 각각 0과 100이에요.
<MeterGroup :value="value" :max="200" />
Composition API Example
<template>
<div class="card">
<MeterGroup :value="value" :max="200" />
</div>
</template>
<script setup>
import { ref } from "vue";
const value = ref([
{ label: 'Apps', color: '#34d399', value: 16 },
{ label: 'Messages', color: '#fbbf24', value: 8 },
{ label: 'Media', color: '#60a5fa', value: 24 },
{ label: 'System', color: '#c084fc', value: 10 }
]);
<\/script>
여러 항목 (Multiple)
배열에 항목을 더 추가하면 미터들이 그룹으로 표시돼요.
<MeterGroup :value="value" />
Composition API Example
<template>
<div class="card">
<MeterGroup :value="value" />
</div>
</template>
<script setup>
import { ref } from "vue";
const value = ref([
{ label: 'Apps', color: '#34d399', value: 16 },
{ label: 'Messages', color: '#fbbf24', value: 8 },
{ label: 'Media', color: '#60a5fa', value: 24 },
{ label: 'System', color: '#c084fc', value: 10 }
]);
<\/script>
템플릿 (Template)
MeterGroup은 라벨, 미터 항목, 미터 주변 콘텐츠에 템플릿 지원을 제공해요.
<MeterGroup :value="value" labelPosition="start">
<template #label="{ value }">
<div class="flex flex-wrap gap-4">
<template v-for="val of value" :key="val.label">
<Card class="flex-1 border border-surface shadow-none">
<template #content>
<div class="flex justify-between gap-8">
<div class="flex flex-col gap-1">
<span class="text-surface-500 dark:text-surface-400 text-sm">{{ val.label }}</span>
<span class="font-bold text-lg">{{ val.value }}%</span>
</div>
<span class="w-8 h-8 rounded-full inline-flex justify-center items-center text-center" :style="{ backgroundColor: \`\${val.color1}\`, color: '#ffffff' }">
<i :class="val.icon" />
</span>
</div>
</template>
</Card>
</template>
</div>
</template>
<template #meter="slotProps">
<span :class="slotProps.class" :style="{ background: \`linear-gradient(to right, \${slotProps.value.color1}, \${slotProps.value.color2})\`, width: slotProps.size }" />
</template>
<template #start="{ totalPercent }">
<div class="flex justify-between mt-4 mb-2 relative">
<span>Storage</span>
<span :style="{ width: totalPercent + '%' }" class="absolute text-right">{{ totalPercent }}%</span>
<span class="font-medium">1TB</span>
</div>
</template>
<template #end>
<div class="flex justify-between mt-4">
<Button label="Manage Storage" variant="outlined" size="small" />
<Button label="Update Plan" size="small" />
</div>
</template>
</MeterGroup>
Composition API Example
<template>
<div class="card">
<MeterGroup :value="value" labelPosition="start">
<template #label="{ value }">
<div class="flex flex-wrap gap-4">
<template v-for="val of value" :key="i">
<Card class="flex-1 border border-surface shadow-none">
<template #content>
<div class="flex justify-between gap-8">
<div class="flex flex-col gap-1">
<span class="text-surface-500 dark:text-surface-400 text-sm">{{ val.label }}</span>
<span class="font-bold text-lg">{{ val.value }}%</span>
</div>
<span class="w-8 h-8 rounded-full inline-flex justify-center items-center text-center" :style="{ backgroundColor: \`\${val.color1}\`, color: '#ffffff' }">
<i :class="val.icon" />
</span>
</div>
</template>
</Card>
</template>
</div>
</template>
<template #meter="slotProps">
<span :class="slotProps.class" :style="{ background: \`linear-gradient(to right, \${slotProps.value.color1}, \${slotProps.value.color2})\`, width: slotProps.size }" />
</template>
<template #start="{ totalPercent }">
<div class="flex justify-between mt-4 mb-2 relative">
<span>Storage</span>
<span :style="{ width: totalPercent + '%' }" class="absolute text-right">{{ totalPercent }}%</span>
<span class="font-medium">1TB</span>
</div>
</template>
<template #end>
<div class="flex justify-between mt-4">
<Button label="Manage Storage" variant="outlined" size="small" />
<Button label="Update Plan" size="small" />
</div>
</template>
</MeterGroup>
</div>
</template>
<script setup>
import { ref } from "vue";
const value = ref([
{ label: 'Apps', color1: '#34d399', color2: '#fbbf24', value: 25, icon: 'pi pi-table' },
{ label: 'Messages', color1: '#fbbf24', color2: '#60a5fa', value: 15, icon: 'pi pi-inbox' },
{ label: 'Media', color1: '#60a5fa', color2: '#c084fc', value: 20, icon: 'pi pi-image' },
{ label: 'System', color1: '#c084fc', color2: '#c084fc', value: 10, icon: 'pi pi-cog' }
]);
<\/script>
세로 방향 (Vertical)
MeterGroup의 레이아웃은 orientation 속성으로 설정하며, horizontal 또는 vertical을 값으로 받아요.
<MeterGroup :value="value" orientation="vertical" labelOrientation="vertical" />
Composition API Example
<template>
<div class="card flex justify-center" style="height: 360px">
<MeterGroup :value="value" orientation="vertical" labelOrientation="vertical" />
</div>
</template>
<script setup>
import { ref } from "vue";
const value = ref([
{ label: 'Apps', color: '#34d399', value: 24 },
{ label: 'Messages', color: '#fbbf24', value: 16 },
{ label: 'Media', color: '#60a5fa', value: 24 },
{ label: 'System', color: '#c084fc', value: 12 }
]);
<\/script>
Meter Group
Props
| 이름 | 타입 | 기본값 | 설명 |
|---|---|---|---|
| value | MeterItem[] | - | metergroup의 현재 값이에요. |
| min | number | 0 | 최소 경계 값이에요. |
| max | number | 100 | 최대 경계 값이에요. |
| orientation | "horizontal" | "vertical" | horizontal | 컴포넌트의 레이아웃을 지정해요. 유효한 값은 'horizontal'과 'vertical'이에요. |
| labelPosition | "start" | "end" | end | 컴포넌트의 라벨 위치를 지정해요. 유효한 값은 'start'와 'end'예요. |
| labelOrientation | "horizontal" | "vertical" | horizontal | 컴포넌트의 라벨 방향을 지정해요. 유효한 값은 'horizontal'과 'vertical'이에요. |
| dt | any | - | 디자인 토큰으로 컴포넌트의 스코프 CSS 변수를 생성해요. |
| pt | PassThrough | - | 컴포넌트 내부 DOM 요소에 속성을 전달하는 데 사용돼요. |
| ptOptions | any | - | 컴포넌트의 passthrough(pt) 옵션을 구성하는 데 사용돼요. |
| unstyled | boolean | false | 활성화하면 코어에서 컴포넌트 관련 스타일을 제거해요. |
Pass Through Options
| 이름 | 타입 | 설명 |
|---|---|---|
| root | MeterGroupPassThroughOptionType | root의 DOM 요소에 속성을 전달하는 데 사용돼요. |
| meters | MeterGroupPassThroughOptionType | meter 컨테이너의 DOM 요소에 속성을 전달하는 데 사용돼요. |
| meter | MeterGroupPassThroughOptionType | meter의 DOM 요소에 속성을 전달하는 데 사용돼요. |
| labelList | MeterGroupPassThroughOptionType | label list의 DOM 요소에 속성을 전달하는 데 사용돼요. |
| label | MeterGroupPassThroughOptionType | label list 항목의 DOM 요소에 속성을 전달하는 데 사용돼요. |
| labelIcon | MeterGroupPassThroughOptionType | label icon 타입의 DOM 요소에 속성을 전달하는 데 사용돼요. |
| labelMarker | MeterGroupPassThroughOptionType | label list 타입의 DOM 요소에 속성을 전달하는 데 사용돼요. |
| labelText | MeterGroupPassThroughOptionType | label의 DOM 요소에 속성을 전달하는 데 사용돼요. |
테마 (Theming)
CSS 클래스 (CSS Classes)
| 클래스 | 설명 |
|---|---|
| p-metergroup | 루트 요소의 클래스 이름이에요. |
| p-metergroup-meters | meters 요소의 클래스 이름이에요. |
| p-metergroup-meter | meter 요소의 클래스 이름이에요. |
| p-metergroup-label-list | label list 요소의 클래스 이름이에요. |
| p-metergroup-label | label 요소의 클래스 이름이에요. |
| p-metergroup-label-icon | label icon 요소의 클래스 이름이에요. |
| p-metergroup-label-marker | label marker 요소의 클래스 이름이에요. |
| p-metergroup-label-text | label text 요소의 클래스 이름이에요. |
디자인 토큰 (Design Tokens)
| 토큰 | CSS 변수 | 설명 |
|---|---|---|
| metergroup.border.radius | --p-metergroup-border-radius | 루트의 보더 반경 |
| metergroup.gap | --p-metergroup-gap | 루트의 간격 |
| metergroup.meters.background | --p-metergroup-meters-background | meters의 배경 |
| metergroup.meters.size | --p-metergroup-meters-size | meters의 크기 |
| metergroup.label.gap | --p-metergroup-label-gap | label의 간격 |
| metergroup.label.marker.size | --p-metergroup-label-marker-size | label marker의 크기 |
| metergroup.label.icon.size | --p-metergroup-label-icon-size | label icon의 크기 |
| metergroup.label.list.vertical.gap | --p-metergroup-label-list-vertical-gap | label list의 세로 간격 |
| metergroup.label.list.horizontal.gap | --p-metergroup-label-list-horizontal-gap | label list의 가로 간격 |
더 알아보기 (Learn more)
MeterGroup은 value 배열로 여러 측정값을 하나의 막대에 나눠 보여줘요. orientation과 labelPosition·labelOrientation으로 배치를 바꾸고, #meter·#label 같은 템플릿 슬롯으로 표시를 완전히 커스터마이징할 수 있어요.