Meter
A graphical display of a numeric value within a range.
<?phem
use Phem\Attribute\Component;
use Phem\Node;
use Phem\Ui\Meter;
use function Phem\Ui\{MeterIndicator, MeterLabel, MeterTrack, MeterValue};
#[Component]
function MeterHeroDemo(): Node
{
return (
<Meter id="storage" value={{ 24 }}>
<MeterLabel>Storage Used</MeterLabel>
<MeterValue />
<MeterTrack>
<MeterIndicator />
</MeterTrack>
</Meter>
);
}
API reference#
Import the components of the family:
use Phem\Ui\Meter;
use function Phem\Ui\{MeterLabel, MeterValue, MeterTrack, MeterIndicator};Meter#
A graphical display of a value in a range: Base UI Meter.Root. Give an id to label it with its MeterLabel.
The text of the value is the rounded percent (24%). The format options (style, currency, minimumFractionDigits, maximumFractionDigits) and the locale change it, as in Base UI: see ValueFormat. They need the intl extension of PHP.
| Prop | Type | Default |
|---|---|---|
value | float | 0 |
min | float | 0 |
max | float | 100 |
id | ?string | null |
format | array | [] |
locale | ?string | null |
children | ?Html | null |
...attrs | array | [] |
MeterLabel#
The label of the meter. It names the meter (aria-labelledby).
| Prop | Type | Default |
|---|---|---|
children | ?Html | null |
...rest | mixed | — |
MeterValue#
The value of the meter as a text, for example 24%. Its children replace the text.
| Prop | Type | Default |
|---|---|---|
children | ?Html | null |
...rest | mixed | — |
MeterIndicator#
The part of the track that shows the value: its width is the percentage of the value.
| Prop | Type | Default |
|---|---|---|
...rest | mixed | — |
MeterTrack#
The bar of the meter: it holds the MeterIndicator.
| Prop | Type | Default |
|---|---|---|
children | ?Html | null |
...rest | mixed | — |
The source of the examples: examples/ui/Meter.phem.