Introducing PrimeReact v11-alpha 🎉Discover Now

MeterGroup

An unstyled meter group component for visualizing scalar measurements within a range.

Build fully custom meter visualizations with complete control over layout and styling.

  1. Apps (16%)
  2. Messages (8%)
  3. Media (24%)
  4. System (10%)
basic-demo

Pre-styled Versions

Choose a pre-styled library to use MeterGroup with ready-made designs.
For hook-based usage without components, see the Headless API.

Features#

  • Compound component API with sub-components: Root, Meters, Meter, Labels, Label, Marker, Icon, Text
  • Built-in color palette with 9 named colors that cycle automatically via index
  • Percentage calculation relative to configurable min/max bounds
  • Horizontal and vertical orientation for both meters and labels

Usage#

import { MeterGroup } from 'primereact/metergroup';
<MeterGroup.Root>
    <MeterGroup.Meters>
        <MeterGroup.Meter />
    </MeterGroup.Meters>
    <MeterGroup.Labels>
        <MeterGroup.Label>
            <MeterGroup.Marker />
            <MeterGroup.Text></MeterGroup.Text>
        </MeterGroup.Label>
    </MeterGroup.Labels>
</MeterGroup.Root>

Behavior#

Polymorphic Rendering#

Use as on any sub-component to change the rendered HTML element.

<MeterGroup.Root as="section"></MeterGroup.Root>
<MeterGroup.Labels as="ul"></MeterGroup.Labels>
<MeterGroup.Label as="div"></MeterGroup.Label>

Default elements: Root=div, Meters=div, Meter=div, Labels=ol, Label=li, Marker=span, Icon=Icon, Text=span.

Render Function Children#

Root accepts a render function as children, providing access to the component instance.

<MeterGroup.Root>{(instance) => <span>Total: {instance.state.totalPercent}%</span>}</MeterGroup.Root>

Pass Through#

Some parts may not be visible in the preview depending on the component's current state.

Loading...
/* Select a part to see its CSS selector for custom styling */

API#

MeterGroupRoot#

NameTypeDefault
refRef<unknown>—
The reference to the component instance.
pIfbooleantrue
Whether the component should be rendered.
styleCSSProperties | ((instance?: MeterGroupRootInstance) => CSSProperties)—
The style to apply to the component.
classNamestring | ((instance?: MeterGroupRootInstance) => string)—
The class name to apply to the component.
asstring | number | bigint | boolean | ComponentClass<any, any> | FunctionComponent<any> | ReactElement<unknown, string | JSXElementConstructor<any>> | Iterable<ReactNode, any, any> | ReactPortal | Promise<AwaitedReactNode>—
The component type to render.
asChildbooleanfalse
Whether the component should be rendered as a child component.
instanceMeterGroupRootInstance—
The instance to pass to the component.
ptSafeRecord<MeterGroupRootPassThrough>—
The pass-through props to pass to the component.
ptOptionsPassThroughOptions—
The pass-through options to pass to the component.
unstyledboolean—
Whether the component should be rendered without classes.
dtunknown—
The design token to use for the component.
stylesStylesOptions<ComponentInstance>—
The styles to use for the component.
render(instance: MeterGroupRootInstance) => ReactNode—
The render function to render the component with instance access.
childrenany—
The children to render. Accepts `React.ReactNode` for static content or a render function `(instance: I) => React.ReactNode` for instance access. Typed as `any` to avoid JSX type errors when used directly in templates.
minnumber0
Minimum boundary value.
maxnumber100
Maximum boundary value.
orientation"horizontal" | "vertical"horizontal
Specifies the layout of the component.
[key: string]any—
pt-{optionName}-*-—
Pass through attributes for customizing component. For more info, see Pass Through tab.
AttributeValue
data-scope"metergroup"
data-part"root"
data-orientationCurrent orientation value

Defines passthrough(pt) options of MeterGroup component.

labeltypedescription
rootMeterGroupRootPassThroughType<HTMLAttributes<HTMLDivElement>>Used to pass attributes to the root's DOM element.
metersMeterGroupRootPassThroughType<HTMLAttributes<HTMLDivElement>>Used to pass attributes to the meters' DOM element.
meterMeterGroupRootPassThroughType<HTMLAttributes<HTMLDivElement>>Used to pass attributes to the meter's DOM element.
labelsMeterGroupRootPassThroughType<HTMLAttributes<HTMLOListElement>>Used to pass attributes to the labels' DOM element.
labelMeterGroupRootPassThroughType<HTMLAttributes<HTMLLIElement>>Used to pass attributes to the label's DOM element.
iconMeterGroupRootPassThroughType<HTMLAttributes<HTMLElement>>Used to pass attributes to the label icon's DOM element.
markerMeterGroupRootPassThroughType<HTMLAttributes<HTMLSpanElement>>Used to pass attributes to the label marker's DOM element.
textMeterGroupRootPassThroughType<HTMLAttributes<HTMLSpanElement>>Used to pass attributes to the root's DOM element.

MeterGroupMeters#

NameTypeDefault
refRef<unknown>—
The reference to the component instance.
pIfbooleantrue
Whether the component should be rendered.
styleCSSProperties | ((instance?: MeterGroupMetersInstance) => CSSProperties)—
The style to apply to the component.
classNamestring | ((instance?: MeterGroupMetersInstance) => string)—
The class name to apply to the component.
asstring | number | bigint | boolean | ComponentClass<any, any> | FunctionComponent<any> | ReactElement<unknown, string | JSXElementConstructor<any>> | Iterable<ReactNode, any, any> | ReactPortal | Promise<AwaitedReactNode>—
The component type to render.
asChildbooleanfalse
Whether the component should be rendered as a child component.
instanceMeterGroupMetersInstance—
The instance to pass to the component.
ptSafeRecord<MeterGroupMetersPassThrough>—
The pass-through props to pass to the component.
ptOptionsPassThroughOptions—
The pass-through options to pass to the component.
unstyledboolean—
Whether the component should be rendered without classes.
dtunknown—
The design token to use for the component.
stylesStylesOptions<ComponentInstance>—
The styles to use for the component.
render(instance: MeterGroupMetersInstance) => ReactNode—
The render function to render the component with instance access.
childrenany—
The children to render. Accepts `React.ReactNode` for static content or a render function `(instance: I) => React.ReactNode` for instance access. Typed as `any` to avoid JSX type errors when used directly in templates.
[key: string]any—
pt-{optionName}-*-—
Pass through attributes for customizing component. For more info, see Pass Through tab.
AttributeValue
data-scope"metergroup"
data-part"meters"

Defines passthrough(pt) options of MeterGroupMeters component.

labeltypedescription
rootMeterGroupMetersPassThroughType<HTMLAttributes<HTMLDivElement>>Used to pass attributes to the root's DOM element.

MeterGroupMeter#

NameTypeDefault
refRef<unknown>—
The reference to the component instance.
pIfbooleantrue
Whether the component should be rendered.
styleCSSProperties | ((instance?: MeterGroupMeterInstance) => CSSProperties)—
The style to apply to the component.
classNamestring | ((instance?: MeterGroupMeterInstance) => string)—
The class name to apply to the component.
asstring | number | bigint | boolean | ComponentClass<any, any> | FunctionComponent<any> | ReactElement<unknown, string | JSXElementConstructor<any>> | Iterable<ReactNode, any, any> | ReactPortal | Promise<AwaitedReactNode>—
The component type to render.
asChildbooleanfalse
Whether the component should be rendered as a child component.
instanceMeterGroupMeterInstance—
The instance to pass to the component.
ptSafeRecord<MeterGroupMeterPassThrough>—
The pass-through props to pass to the component.
ptOptionsPassThroughOptions—
The pass-through options to pass to the component.
unstyledboolean—
Whether the component should be rendered without classes.
dtunknown—
The design token to use for the component.
stylesStylesOptions<ComponentInstance>—
The styles to use for the component.
render(instance: MeterGroupMeterInstance) => ReactNode—
The render function to render the component with instance access.
childrenany—
The children to render. Accepts `React.ReactNode` for static content or a render function `(instance: I) => React.ReactNode` for instance access. Typed as `any` to avoid JSX type errors when used directly in templates.
valuenumber—
Defines the value of the meter.
colorstring & {} | METERGROUP_DEFAULT_COLORS_TYPE—
Defines the color of the meter.
indexnumber—
Defines the index of the meter.
[key: string]any—
pt-{optionName}-*-—
Pass through attributes for customizing component. For more info, see Pass Through tab.
AttributeValue
data-scope"metergroup"
data-part"meter"

Defines passthrough(pt) options of MeterGroupMeter component.

labeltypedescription
rootMeterGroupMeterPassThroughType<HTMLAttributes<HTMLDivElement>>Used to pass attributes to the root's DOM element.

MeterGroupLabels#

NameTypeDefault
refRef<unknown>—
The reference to the component instance.
pIfbooleantrue
Whether the component should be rendered.
styleCSSProperties | ((instance?: MeterGroupLabelsInstance) => CSSProperties)—
The style to apply to the component.
classNamestring | ((instance?: MeterGroupLabelsInstance) => string)—
The class name to apply to the component.
asstring | number | bigint | boolean | ComponentClass<any, any> | FunctionComponent<any> | ReactElement<unknown, string | JSXElementConstructor<any>> | Iterable<ReactNode, any, any> | ReactPortal | Promise<AwaitedReactNode>—
The component type to render.
asChildbooleanfalse
Whether the component should be rendered as a child component.
instanceMeterGroupLabelsInstance—
The instance to pass to the component.
ptSafeRecord<MeterGroupLabelsPassThrough>—
The pass-through props to pass to the component.
ptOptionsPassThroughOptions—
The pass-through options to pass to the component.
unstyledboolean—
Whether the component should be rendered without classes.
dtunknown—
The design token to use for the component.
stylesStylesOptions<ComponentInstance>—
The styles to use for the component.
render(instance: MeterGroupLabelsInstance) => ReactNode—
The render function to render the component with instance access.
childrenany—
The children to render. Accepts `React.ReactNode` for static content or a render function `(instance: I) => React.ReactNode` for instance access. Typed as `any` to avoid JSX type errors when used directly in templates.
orientation"horizontal" | "vertical"horizontal
Specifies the label orientation of the component.
[key: string]any—
pt-{optionName}-*-—
Pass through attributes for customizing component. For more info, see Pass Through tab.
AttributeValue
data-scope"metergroup"
data-part"labels"

Defines passthrough(pt) options of MeterGroupLabels component.

labeltypedescription
rootMeterGroupLabelsPassThroughType<HTMLAttributes<HTMLDivElement>>Used to pass attributes to the root's DOM element.

MeterGroupLabel#

NameTypeDefault
refRef<unknown>—
The reference to the component instance.
pIfbooleantrue
Whether the component should be rendered.
styleCSSProperties | ((instance?: MeterGroupLabelInstance) => CSSProperties)—
The style to apply to the component.
classNamestring | ((instance?: MeterGroupLabelInstance) => string)—
The class name to apply to the component.
asstring | number | bigint | boolean | ComponentClass<any, any> | FunctionComponent<any> | ReactElement<unknown, string | JSXElementConstructor<any>> | Iterable<ReactNode, any, any> | ReactPortal | Promise<AwaitedReactNode>—
The component type to render.
asChildbooleanfalse
Whether the component should be rendered as a child component.
instanceMeterGroupLabelInstance—
The instance to pass to the component.
ptSafeRecord<MeterGroupLabelPassThrough>—
The pass-through props to pass to the component.
ptOptionsPassThroughOptions—
The pass-through options to pass to the component.
unstyledboolean—
Whether the component should be rendered without classes.
dtunknown—
The design token to use for the component.
stylesStylesOptions<ComponentInstance>—
The styles to use for the component.
render(instance: MeterGroupLabelInstance) => ReactNode—
The render function to render the component with instance access.
childrenany—
The children to render. Accepts `React.ReactNode` for static content or a render function `(instance: I) => React.ReactNode` for instance access. Typed as `any` to avoid JSX type errors when used directly in templates.
colorstring—
Defines the color of the label.
[key: string]any—
pt-{optionName}-*-—
Pass through attributes for customizing component. For more info, see Pass Through tab.
AttributeValue
data-scope"metergroup"
data-part"label"

Defines passthrough(pt) options of MeterGroupLabel component.

labeltypedescription
rootMeterGroupLabelPassThroughType<HTMLAttributes<HTMLLIElement>>Used to pass attributes to the root's DOM element.

MeterGroupMarker#

NameTypeDefault
refRef<unknown>—
The reference to the component instance.
pIfbooleantrue
Whether the component should be rendered.
styleCSSProperties | ((instance?: MeterGroupMarkerInstance) => CSSProperties)—
The style to apply to the component.
classNamestring | ((instance?: MeterGroupMarkerInstance) => string)—
The class name to apply to the component.
asstring | number | bigint | boolean | ComponentClass<any, any> | FunctionComponent<any> | ReactElement<unknown, string | JSXElementConstructor<any>> | Iterable<ReactNode, any, any> | ReactPortal | Promise<AwaitedReactNode>—
The component type to render.
asChildbooleanfalse
Whether the component should be rendered as a child component.
instanceMeterGroupMarkerInstance—
The instance to pass to the component.
ptSafeRecord<MeterGroupMarkerPassThrough>—
The pass-through props to pass to the component.
ptOptionsPassThroughOptions—
The pass-through options to pass to the component.
unstyledboolean—
Whether the component should be rendered without classes.
dtunknown—
The design token to use for the component.
stylesStylesOptions<ComponentInstance>—
The styles to use for the component.
render(instance: MeterGroupMarkerInstance) => ReactNode—
The render function to render the component with instance access.
childrenany—
The children to render. Accepts `React.ReactNode` for static content or a render function `(instance: I) => React.ReactNode` for instance access. Typed as `any` to avoid JSX type errors when used directly in templates.
colorstring & {} | METERGROUP_DEFAULT_COLORS_TYPE—
Defines the color of the marker.
indexnumber—
Defines the index of the marker.
[key: string]any—
pt-{optionName}-*-—
Pass through attributes for customizing component. For more info, see Pass Through tab.
AttributeValue
data-scope"metergroup"
data-part"marker"

Defines passthrough(pt) options of MeterGroupMarker component.

labeltypedescription
rootMeterGroupMarkerPassThroughType<HTMLAttributes<HTMLDivElement>>Used to pass attributes to the root's DOM element.

MeterGroupIcon#

NameTypeDefault
refRef<unknown>—
The reference to the component instance.
pIfbooleantrue
Whether the component should be rendered.
styleCSSProperties | ((instance?: MeterGroupIconInstance) => CSSProperties)—
The style to apply to the component.
classNamestring | ((instance?: MeterGroupIconInstance) => string)—
The class name to apply to the component.
asstring | number | bigint | boolean | ComponentClass<any, any> | FunctionComponent<any> | ReactElement<unknown, string | JSXElementConstructor<any>> | Iterable<ReactNode, any, any> | ReactPortal | Promise<AwaitedReactNode>—
The component type to render.
asChildbooleanfalse
Whether the component should be rendered as a child component.
instanceMeterGroupIconInstance—
The instance to pass to the component.
ptSafeRecord<MeterGroupIconPassThrough>—
The pass-through props to pass to the component.
ptOptionsPassThroughOptions—
The pass-through options to pass to the component.
unstyledboolean—
Whether the component should be rendered without classes.
dtunknown—
The design token to use for the component.
stylesStylesOptions<ComponentInstance>—
The styles to use for the component.
render(instance: MeterGroupIconInstance) => ReactNode—
The render function to render the component with instance access.
childrenany—
The children to render. Accepts `React.ReactNode` for static content or a render function `(instance: I) => React.ReactNode` for instance access. Typed as `any` to avoid JSX type errors when used directly in templates.
[key: string]any—
pt-{optionName}-*-—
Pass through attributes for customizing component. For more info, see Pass Through tab.
AttributeValue
data-scope"metergroup"
data-part"icon"

Defines passthrough(pt) options of MeterGroupIcon component.

labeltypedescription
rootMeterGroupIconPassThroughType<HTMLAttributes<HTMLDivElement>>Used to pass attributes to the root's DOM element.

MeterGroupText#

NameTypeDefault
refRef<unknown>—
The reference to the component instance.
pIfbooleantrue
Whether the component should be rendered.
styleCSSProperties | ((instance?: MeterGroupTextInstance) => CSSProperties)—
The style to apply to the component.
classNamestring | ((instance?: MeterGroupTextInstance) => string)—
The class name to apply to the component.
asstring | number | bigint | boolean | ComponentClass<any, any> | FunctionComponent<any> | ReactElement<unknown, string | JSXElementConstructor<any>> | Iterable<ReactNode, any, any> | ReactPortal | Promise<AwaitedReactNode>—
The component type to render.
asChildbooleanfalse
Whether the component should be rendered as a child component.
instanceMeterGroupTextInstance—
The instance to pass to the component.
ptSafeRecord<MeterGroupTextPassThrough>—
The pass-through props to pass to the component.
ptOptionsPassThroughOptions—
The pass-through options to pass to the component.
unstyledboolean—
Whether the component should be rendered without classes.
dtunknown—
The design token to use for the component.
stylesStylesOptions<ComponentInstance>—
The styles to use for the component.
render(instance: MeterGroupTextInstance) => ReactNode—
The render function to render the component with instance access.
childrenany—
The children to render. Accepts `React.ReactNode` for static content or a render function `(instance: I) => React.ReactNode` for instance access. Typed as `any` to avoid JSX type errors when used directly in templates.
[key: string]any—
pt-{optionName}-*-—
Pass through attributes for customizing component. For more info, see Pass Through tab.
AttributeValue
data-scope"metergroup"
data-part"text"

Defines passthrough(pt) options of MeterGroupText component.

labeltypedescription
rootMeterGroupTextPassThroughType<HTMLAttributes<HTMLDivElement>>Used to pass attributes to the root's DOM element.

Accessibility#

Screen Reader#

MeterGroup component uses meter role in addition to the aria-valuemin, aria-valuemax and aria-valuenow attributes. Value to describe the component can be defined using aria-labelledby prop.

Keyboard Support#

Component does not include any interactive elements.