Meter
A graphical display of a numeric value within a range.
Storage Used
import { Meter } from 'base-ui-solid/meter';
import styles from './index.module.css';
export default function ExampleMeter() {
return (
<Meter.Root class={styles.Meter} value={24}>
<Meter.Label class={styles.Label}>Storage Used</Meter.Label>
<Meter.Value class={styles.Value} />
<Meter.Track class={styles.Track}>
<Meter.Indicator class={styles.Indicator} />
</Meter.Track>
</Meter.Root>
);
}
Anatomy
Import the component and assemble its parts:
Anatomy
import { Meter } from 'base-ui-solid/meter';
<Meter.Root>
<Meter.Label />
<Meter.Track>
<Meter.Indicator />
</Meter.Track>
<Meter.Value />
</Meter.Root>;
API reference
Root
Groups all parts of the meter and provides the value for screen readers.
Renders a <div> element.
Prop
Type
Default
value*number—
The current value.
numberaria-valuetextstring—
A string value that provides a user-friendly name for
aria-valuenow, the current value of the meter.stringgetAriaValueTextfunction—
A function that returns a string value that provides a human-readable text alternative for
aria-valuenow, the current value of the meter.((formattedValue: string, value: number) => string)localeIntl.LocalesArgument—
The locale used by
Intl.NumberFormat when formatting the value.
Defaults to the user’s runtime locale.
When server rendering, en-US is used until hydration.Intl.LocalesArgumentminnumber0
The minimum value
numbermaxnumber100
The maximum value
numberformatIntl.NumberFormatOptions—
Options to format the value.
Intl.NumberFormatOptionsclassfunction—
CSS class applied to the element, or a function that
returns a class based on the component’s state.
JSX.ClassValue | ((state) => JSX.ClassValue)stylefunction—
Style applied to the element, or a function that
returns a style object based on the component’s state.
JSX.CSSProperties | string | ((state) => JSX.CSSProperties | string | undefined)renderfunction—
Replace the default element with a tag name, component, or render function.
keyof JSX.IntrinsicElements | Component | ((props, state) => JSX.Element)Root.State
type MeterRootState = {};Track
Contains the meter indicator and represents the entire range of the meter.
Renders a <div> element.
Prop
Type
Default
classfunction—
CSS class applied to the element, or a function that
returns a class based on the component’s state.
JSX.ClassValue | ((state) => JSX.ClassValue)stylefunction—
Style applied to the element, or a function that
returns a style object based on the component’s state.
JSX.CSSProperties | string | ((state) => JSX.CSSProperties | string | undefined)renderfunction—
Replace the default element with a tag name, component, or render function.
keyof JSX.IntrinsicElements | Component | ((props, state) => JSX.Element)Track.State
type MeterTrackState = {};Indicator
Visualizes the position of the value along the range.
Renders a <div> element.
Prop
Type
Default
classfunction—
CSS class applied to the element, or a function that
returns a class based on the component’s state.
JSX.ClassValue | ((state) => JSX.ClassValue)stylefunction—
Style applied to the element, or a function that
returns a style object based on the component’s state.
JSX.CSSProperties | string | ((state) => JSX.CSSProperties | string | undefined)renderfunction—
Replace the default element with a tag name, component, or render function.
keyof JSX.IntrinsicElements | Component | ((props, state) => JSX.Element)Indicator.State
type MeterIndicatorState = {};Value
A children function is called once with accessors of the formatted value and the value, so read them in JSX to keep the text up to date (see Reactivity).
A text element displaying the current value.
Renders a <span> element.
Prop
Type
Default
childrenfunction—
A render function is called once with its arguments as accessors, so read them in JSX to keep the content up to date.
((formattedValue: Accessor<string>, value: Accessor<number>) => JSX.Element) | nullclassfunction—
CSS class applied to the element, or a function that
returns a class based on the component’s state.
JSX.ClassValue | ((state) => JSX.ClassValue)stylefunction—
Style applied to the element, or a function that
returns a style object based on the component’s state.
JSX.CSSProperties | string | ((state) => JSX.CSSProperties | string | undefined)renderfunction—
Replace the default element with a tag name, component, or render function.
keyof JSX.IntrinsicElements | Component | ((props, state) => JSX.Element)Value.State
type MeterValueState = {};Label
An accessible label for the meter.
Renders a <span> element.
Prop
Type
Default
classfunction—
CSS class applied to the element, or a function that
returns a class based on the component’s state.
JSX.ClassValue | ((state) => JSX.ClassValue)stylefunction—
Style applied to the element, or a function that
returns a style object based on the component’s state.
JSX.CSSProperties | string | ((state) => JSX.CSSProperties | string | undefined)renderfunction—
Replace the default element with a tag name, component, or render function.
keyof JSX.IntrinsicElements | Component | ((props, state) => JSX.Element)Label.State
type MeterLabelState = {};