Meter
A graphical display of a numeric value within a range.
View as MarkdownAnatomy
Import the component and assemble its parts:
import { Meter } from '@base-ui/react/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.
value*number—
number- Name
- Description
The current value.
- Type
number
aria-valuetextstring—
string- Name
- Description
A string value that provides a user-friendly name for
aria-valuenow, the current value of the meter.- Type
string | undefined
getAriaValueTextfunction—
function- Name
- Description
A function that returns a string value that provides a human-readable text alternative for
aria-valuenow, the current value of the meter.- Type
| ((formattedValue: string, value: number) => string) | undefined
localeIntl.LocalesArgument—
Intl.LocalesArgument- Name
- Description
The locale used by
Intl.NumberFormatwhen formatting the value. Defaults to the user’s runtime locale.- Type
Intl.LocalesArgument | undefined
minnumber0
number- Name
- Description
The minimum value
- Type
number | undefined- Default
0
maxnumber100
number- Name
- Description
The maximum value
- Type
number | undefined- Default
100
formatIntl.NumberFormatOptions—
Intl.NumberFormatOptions- Name
- Description
Options to format the value.
- Type
Intl.NumberFormatOptions | undefined
classNamestring | function—
string | function- Name
- Description
CSS class applied to the element, or a function that returns a class based on the component’s state.
- Type
| string | ((state: Meter.Root.State) => string | undefined) | undefined
styleReact.CSSProperties | function—
React.CSSProperties | function- Name
- Type
| React.CSSProperties | (( state: Meter.Root.State, ) => React.CSSProperties | undefined) | undefined
renderReactElement | function—
ReactElement | function- Name
- Description
Allows you to replace the component’s HTML element with a different tag, or compose it with another component.
Accepts a
ReactElementor a function that returns the element to render.- Type
| ReactElement | (( props: HTMLProps, state: Meter.Root.State, ) => ReactElement) | undefined
Additional Types
Meter.Root.Props
Re-Export of Root props as MeterRootProps
Meter.Root.State
type MeterRootState = {};Track
Contains the meter indicator and represents the entire range of the meter.
Renders a <div> element.
classNamestring | function—
string | function- Name
- Description
CSS class applied to the element, or a function that returns a class based on the component’s state.
- Type
| string | ((state: Meter.Root.State) => string | undefined) | undefined
styleReact.CSSProperties | function—
React.CSSProperties | function- Name
- Type
| React.CSSProperties | (( state: Meter.Root.State, ) => React.CSSProperties | undefined) | undefined
renderReactElement | function—
ReactElement | function- Name
- Description
Allows you to replace the component’s HTML element with a different tag, or compose it with another component.
Accepts a
ReactElementor a function that returns the element to render.- Type
| ReactElement | (( props: HTMLProps, state: Meter.Root.State, ) => ReactElement) | undefined
Additional Types
Meter.Track.Props
Re-Export of Track props as MeterTrackProps
Indicator
Visualizes the position of the value along the range.
Renders a <div> element.
classNamestring | function—
string | function- Name
- Description
CSS class applied to the element, or a function that returns a class based on the component’s state.
- Type
| string | ((state: Meter.Root.State) => string | undefined) | undefined
styleReact.CSSProperties | function—
React.CSSProperties | function- Name
- Type
| React.CSSProperties | (( state: Meter.Root.State, ) => React.CSSProperties | undefined) | undefined
renderReactElement | function—
ReactElement | function- Name
- Description
Allows you to replace the component’s HTML element with a different tag, or compose it with another component.
Accepts a
ReactElementor a function that returns the element to render.- Type
| ReactElement | (( props: HTMLProps, state: Meter.Root.State, ) => ReactElement) | undefined
Additional Types
Meter.Indicator.Props
Re-Export of Indicator props as MeterIndicatorProps
Value
A text element displaying the current value.
Renders a <span> element.
children| ((formattedValue: string, value: number) => React.ReactNode)
| null—
| ((formattedValue: string, value: number) => React.ReactNode)
| null- Name
- Type
((formattedValue: string, value: number) => React.ReactNode) | null | undefined
classNamestring | function—
string | function- Name
- Description
CSS class applied to the element, or a function that returns a class based on the component’s state.
- Type
| string | ((state: Meter.Root.State) => string | undefined) | undefined
styleReact.CSSProperties | function—
React.CSSProperties | function- Name
- Type
| React.CSSProperties | (( state: Meter.Root.State, ) => React.CSSProperties | undefined) | undefined
renderReactElement | function—
ReactElement | function- Name
- Description
Allows you to replace the component’s HTML element with a different tag, or compose it with another component.
Accepts a
ReactElementor a function that returns the element to render.- Type
| ReactElement | (( props: HTMLProps, state: Meter.Root.State, ) => ReactElement) | undefined
Additional Types
Meter.Value.Props
Re-Export of Value props as MeterValueProps
Label
An accessible label for the meter.
Renders a <span> element.
classNamestring | function—
string | function- Name
- Description
CSS class applied to the element, or a function that returns a class based on the component’s state.
- Type
| string | ((state: Meter.Root.State) => string | undefined) | undefined
styleReact.CSSProperties | function—
React.CSSProperties | function- Name
- Type
| React.CSSProperties | (( state: Meter.Root.State, ) => React.CSSProperties | undefined) | undefined
renderReactElement | function—
ReactElement | function- Name
- Description
Allows you to replace the component’s HTML element with a different tag, or compose it with another component.
Accepts a
ReactElementor a function that returns the element to render.- Type
| ReactElement | (( props: HTMLProps, state: Meter.Root.State, ) => ReactElement) | undefined
Additional Types
Meter.Label.Props
Re-Export of Label props as MeterLabelProps