Meter
A gauge that shows a quantity within a known range.
Installation
Included in poetry-ui — available as
poetry_meter
the moment you've installed Poetry,
with no per-component step. To own the source and edit it, copy it into your app:
bin/rails g poetry:add meter
Default
Open Default standalone
Storage used62%
<%= poetry_meter(value: 62, label: "Storage used", class: "w-64") %>
With value text
Open With value text standalone
Seats3 of 4 seats
<%# value_text: replaces the readout AND aria-valuetext verbatim. %>
<%= poetry_meter(value: 3, max: 4, label: "Seats", value_text: "3 of 4 seats", class: "w-64") %>
API
Poetry::Ui::Meter::Component — options are
constructor keywords (the poetry_* helper forwards them);
slots are composed inside the block. Generated from the gem's source documentation.
| Option | Type | Details | Description |
|---|---|---|---|
| label: | String | required | The meter's accessible name and visible caption. |
| max: | Integer | defaults to 100 |
The range's upper bound - must exceed min:. |
| min: | Integer | defaults to 0 |
The range's lower bound. |
| show_value: | Boolean | defaults to true |
Set false to hide the visible readout. |
| value: | Integer | required | The measured quantity, clamped into min:..max:. |
| value_text: | String | Verbatim human-readable value (\"3 of 4 seats\") replacing the percentage readout. Visible readout only - ARIA 1.2 deprecated aria-valuetext on role=meter, so aria-valuenow carries the value. |
Styling
Every part carries a stable data-slot attribute — target
[data-slot=…] from your own CSS to restyle it. State rides
data attributes on the parts below. This contract is verified against rendered DOM in CI.
| Part | Description |
|---|---|
| [data-slot=meter] | Root (role=meter, aria-value*, and the accessible name); label, readout, and track stack here |
| [data-slot=meter-label] | The visible caption span (label:) |
| [data-slot=meter-value] | The readout - value_text: verbatim, else the range percentage; renders unless show_value: false |
| [data-slot=meter-track] | The full-width rail (Progress's cn chrome) |
| [data-slot=meter-indicator] | The filled bar - inline width percentage of the range |