Hulian UIv0.93.5413 components0 components
  • Start
  • Components
  • Blocks
  • Pages
  • Demos
  • Changelog
ChineseEnglish
  • ComponentsComponents
  • ThemeTheme

Collections

  • QuestionCard
  • Table
  • Book3D
  • ProTable
  • PricingTable
  • JsonViewer
  • EditableTable
  • List
  • Descriptions
  • RowActions
  • Tree
  • Card
  • Carousel
  • Video
  • Audio
  • BentoGrid
  • Image
  • MagicCard
  • AnimatedList
  • Marquee
  • Sortable
  • Kanban
  • DesignCanvas
  • LayerTree
  • StageDraw
  • SlideDeck
  • PresenterView
  • ComponentPicker
  • EventStream
  • QueueLane
  • DocumentSheet
  • Novel reader
  • Scheduler
  • Org classroom
  • Danmaku
  • LiveChat
  • LivePlayer
  • LogViewer
  • FileTree
  • CodeReviewThread
  • VirtualList
  • InfiniteScroll
  • LogoLoop
  • BounceCards
  • CardSwap
  • ChromaGrid
  • CircularGallery
  • DomeGallery
  • FlyingPosters
  • InfiniteMenu
  • MagicBento
  • ScrollStack
  • ProfileCard
  • TiltedCard
  • PixelCard
  • DecayCard
  • ReflectiveCard
  • Folder

Charts and Diagrams

  • Flow
  • Diagram
  • Paper
  • SequenceDiagram
  • Sankey
  • Sparkline
  • Funnel
  • Treemap
  • Gantt
  • Heatmap
  • ContributionGraph
  • Legend
  • Chart
  • WorldMap

Information

  • ImageViewer
  • LiveProductCard
  • DiffStat
  • ScoreRing
  • ScoreScale
  • Badge
  • Dot
  • StatusDot
  • Chip
  • FilterChip
  • Coupon
  • Tag
  • Annotation
  • Avatar
  • AvatarCircles
  • User
  • QRCode
  • Comment
  • RelativeTime
  • GitCommit
  • DeployStatus
  • ShieldBadge
  • AwardBadge
  • CreditCard
  • IconTile

Metrics

  • Stat
  • Statistic
  • Meter
  • Timeline
  • NumberTicker

Placeholders

  • Empty
  • Skeleton
  • Watermark

Meter

meter

Displays a value within a known range using a semantic gauge bar.

Usage

Basic usage

Pass in value to render the measurement bar (default 0–100), and role=meter to express the static quantity ratio.

x
tsx
<Meter value={64} />

Labels and values

label and showValue display descriptions and formatted values ​​above the track.

Disk usage72%
x
tsx
<Meter value={72} label="Disk usage" showValue />

Customized range

min/max Customize the upper and lower limits, and the values ​​are converted into proportions according to the interval.

Rating72%
x
tsx
<Meter value={3.6} min={0} max={5} label="Rating" showValue />

Absolute wording

formatValue takes over the value text, so the visible string and the aria-valuetext a screen reader announces are one and the same sentence.

Linked to textbook1041 / 1324 questions
x
tsx
<Meter
  value={1041}
  max={1324}
  label="Linked to textbook"
  showValue
  formatValue={({ value, max }) => `${value} / ${max} questions`}
/>

Different proportions

The proportion is determined by value, and the width is calculated internally by Base UI.

Battery18%
x
Completion100%
x
tsx
<>
  <Meter value={18} label="Power" showValue />
  <Meter value={100} label="Completion" showValue />
</>

When to use

Use Meter for current disk, battery, quota, or other capacity. Meter communicates how full a quantity is now through role="meter"; Progress communicates advancement of a task.

Import

ts
import { Meter } from "@hulianui/ui"

Props

NameTypeDefaultDescription
value*number-Current value.
minnumber0Lower bound.
maxnumber100Upper bound.
showValuebooleanfalseShows the value text. It reads (value - min) / (max - min) as a percentage, matching the indicator, with at most one decimal.
formatValue(info: { value, min, max, percent }) => string-Custom value text. The returned string drives both the visible text and aria-valuetext, so the two can never disagree. percent is already normalized and clamped to 0-100 (not rounded). Use it for absolute wording: ({ value, max }) => \${value} / ${max} questions\``.
classNamestring-Custom class, commonly used for width.

Slots

SlotTypeDescription
labelReactNodeLabel such as "Disk usage". This is the only way to give role="meter" an accessible name (it is wired through aria-labelledby); without it the meter is unnamed to a screen reader, and a heading you draw yourself does not count.

Pitfalls

Use Progress for an advancing task, not Meter. The parent determines bar width, so give it an explicit width.

  • Only label provides the accessible name. role="meter" is wired to it through aria-labelledby, so a heading rendered outside the component is never associated.
  • Asserting on textContent picks up a stray x. Base UI's Meter.Root always appends a visually hidden <span role="presentation">x</span>; a screen reader ignores it and it never joins the accessible name. Query the specific node instead of reading the whole tree.
  • A value outside [min, max] clamps the text to 0-100%, while aria-valuenow still reports the raw value. Out-of-range data is yours to fix; the component does not paper over it.

Related

Stat · Statistic · Chart · Timeline · NumberTicker · WorldMap

Playground

Dosage64%
x
<Meter value={64} label="Dosage" showValue />
PreviousChartData DisplayNextTimeline

On this page

  • Usage
  • Documentation
    • When to use
    • Import
    • Props
    • Slots
    • Pitfalls
    • Related
  • Playground