145a208687
HD-04 scope, against heroui ce90ea3 cn sources: - stale/fictional content: input.md no longer claims TextField is unmigrated; color-field.md no longer claims ColorPicker is private; header.md drops the fictional Header.Root subcomponent and the stale 'menus not migrated' wording (MenuSection label registration is now documented from HeaderRoot source); radio-group.md drops three copied CheckboxGroup wordings (variant override is Radio's, scalar emits, native single-value submit); input-otp.md drops the fictional data-complete state and lists the real missing upstream props - toggle-button disabled row now matches the real CSS hooks (:disabled / [aria-disabled], with data-disabled as a marker only) - part API / CSS classes / interactive states restored per pinned sources: button (full class lists + real variable-based global CSS), accordion (per-part tables + variant/state lists), card (per-part tables + variant list), switch (SwitchGroup snippet + Switch/ SwitchGroup class lists + states), color-field Group (class list + states), input-otp (variant notes, global CSS, class/state lists); input-group gains the two upstream usage chapters - RelatedComponents restored from the pinned componentRelationships (first-3, filtered against componentsMap): 64 pages rewritten, list-box/slider sections added, 7 empty-mapping pages' fabricated entries removed; RelatedShowcases left unmigrated with its real data inventory recorded (2 cases, showcase-site cards) - defaults unified on implementation evidence: granularity (inferred day/minute) and visibleYears (full min-max span, no "or 20" fallback); HD-03 hand-offs resolved (trigger focus-visible noted for HD-06, width guards kept) - new demos: header-collection-grouping (MenuSection/ListBoxSection label wiring), empty-state-collection (collection empty slot); empty-state page deduplicated with a boundary compatibility note - ComponentPreview minHeight/isBgSolid restored per the 30 upstream marks; tabs-overflow max-w-full kept after measuring internal scroll - tests: +3 header registration/demo cases, +1 empty-state collection case; full suite 110 files / 1630 tests, typecheck and build:docs pass
5.8 KiB
5.8 KiB
title, description, component, group
| title | description | component | group |
|---|---|---|---|
| Meter 计量条 | Meter 表示已知范围内的数量,或一个比例值。 | meter | 组件 |
用法
<script setup lang="ts">
import {
Label,
Meter,
MeterFill,
MeterOutput,
MeterTrack,
} from "@heroui-vue/components";
</script>
<template>
<Meter aria-label="存储空间" class="w-64" :value="60">
<Label>存储空间</Label>
<MeterOutput />
<MeterTrack>
<MeterFill />
</MeterTrack>
</Meter>
</template>
组件结构
<script setup lang="ts">
import {
Label,
Meter,
MeterFill,
MeterOutput,
MeterTrack,
} from "@heroui-vue/components";
</script>
<template>
<Meter :value="60">
<Label>Storage</Label>
<MeterOutput />
<MeterTrack>
<MeterFill />
</MeterTrack>
</Meter>
</template>
Meter 渲染为 role="meter progressbar" 的容器(与 React Aria Meter 一致,兼容不支持 meter 角色的浏览器)。Meter 始终有值,没有不确定进度状态。
示例
尺寸
颜色
无可见标签
无需可见标签时,使用 aria-label 提供无障碍标签。
自定义取值范围与格式
使用 minValue、maxValue 与 formatOptions 自定义取值范围与显示格式。
自定义样式
Tailwind CSS
全局 CSS
若要自定义组件类,可使用 @layer components 指令。
@layer components {
.hv-meter {
@apply w-full gap-2;
}
.hv-meter__track {
@apply h-3 rounded-full;
}
.hv-meter__fill {
@apply rounded-full;
}
}
样式参考
HeroUI 遵循 BEM 方法论,确保组件变体与状态可复用且易于自定义。类名前缀为 hv-。
CSS 类
Meter 使用以下 CSS 类(查看源码样式):
基础与元素类 [!toc]
.hv-meter— 基础容器(grid 布局).hv-meter__output— 数值文本展示.hv-meter__track— 轨道背景.hv-meter__fill— 轨道已填充部分
尺寸类 [!toc]
.hv-meter--sm— 小尺寸变体(更细的轨道).hv-meter--md— 中等尺寸变体(默认).hv-meter--lg— 大尺寸变体(更粗的轨道)
颜色类 [!toc]
.hv-meter--default— 默认颜色变体.hv-meter--accent— 强调色变体.hv-meter--success— 成功色变体.hv-meter--warning— 警告色变体.hv-meter--danger— 危险色变体
API 参考
Meter
取值语义与 ProgressBar 相同,但没有 isIndeterminate。role 为 meter progressbar。
| 属性 | 类型 | 默认值 | 描述 |
|---|---|---|---|
value |
number |
0 |
当前值 |
minValue |
number |
0 |
最小值 |
maxValue |
number |
100 |
最大值 |
size |
"sm" | "md" | "lg" |
"md" |
Meter 轨道尺寸 |
color |
"default" | "accent" | "success" | "warning" | "danger" |
"accent" |
填充条颜色 |
formatOptions |
Intl.NumberFormatOptions |
{ style: "percent" } |
数值展示的格式化选项 |
valueLabel |
string | number |
- | 自定义数值标签内容 |
class |
string | Array | Object |
- | 合并到根元素 |
| 默认插槽 | { percentage, valueText } |
- | 内容或作用域插槽 |
MeterRenderProps
| 属性 | 类型 | 描述 |
|---|---|---|
percentage |
number |
Meter 百分比(0–100) |
valueText |
string |
格式化后的数值文本 |
作用域插槽同时提供 isIndeterminate: false,便于与 ProgressBar 插槽结构复用。
MeterOutput
| 属性 | 类型 | 默认值 | 描述 |
|---|---|---|---|
class |
string | Array | Object |
- | 合并到 span |
| 默认插槽 | - | - | 覆盖默认的 valueText 展示 |
渲染为 span[data-slot="meter-output"]。
MeterTrack
| 属性 | 类型 | 默认值 | 描述 |
|---|---|---|---|
class |
string | Array | Object |
- | 合并到 div |
| 默认插槽 | - | - | 通常放置 Fill |
渲染为 div[data-slot="meter-track"]。
MeterFill
| 属性 | 类型 | 默认值 | 描述 |
|---|---|---|---|
class |
string | Array | Object |
- | 合并到 div |
style |
StyleValue |
- | 与计算宽度合并 |
渲染为 div[data-slot="meter-fill"],宽度为 percentage%。