Skip to content

Segmented bar

Pro

One whole in a few parts, as a bar that prints its figures or a thin bar above a list of the parts; parts with an order can take the theme's ramp, lightest to darkest (the reverse in dark mode). Not an M3 component (@windmorph/react-pro).

import { SegmentedBar, SegmentedList } from '@windmorph/react-pro/charts';

Part of Windmorph Pro, paid components on the free core, not on sale yet. See the Pro guide for what it includes and to register interest.

Props

By name or description, across the 30 props below

SegmentedBar 15 props

  • partstype readonly ChartPart[]Required

    The parts of the whole, in the app's order. Six at most (five ordered); more fold into "Other".

  • formatValuetype ChartFormatterdefault Intl.NumberFormat in the page's locale

    Formats an amount.

  • formatSharetype ChartFormatterdefault a whole percentage

    Formats a share, 0 to 1.

  • texturetype booleandefault with two or more parts

    A pattern per part (a hatch; "Other" always has its dots), so no reader depends on hue (WCAG 1.4.1); false turns it off. Always on in forced colours.

  • orderedtype booleandefault false

    The parts have an order (ratings from 1 to 5, age bands): drawn in one hue, from the lightest step of the theme's ramp to the darkest (the reverse in dark mode), five at most; a pinned slot doesn't apply.

  • reftype Ref<HTMLDivElement>

    Ref to the outermost element.

  • idtype string

    The outermost element's id.

Text

  • aria-labeltype string

    Names the whole. In a ChartFrame, its title does unless this is given.

  • aria-labelledbytype string

    The id of what names it.

  • aria-describedbytype string

    The id of what describes it.

  • aria-detailstype string

    The id of what gives more about it.

  • labelstype Partial<ChartLabels>

    Words it says. A LabelsProvider sets them for the whole app.

Also accepts the root element's HTML attributes (id, data-*, event handlers).

SegmentedList 15 props

  • partstype readonly ChartPart[]Required

    The parts of the whole, in the app's order. Six at most (five ordered); more fold into "Other".

  • formatValuetype ChartFormatterdefault Intl.NumberFormat in the page's locale

    Formats an amount.

  • formatSharetype ChartFormatterdefault a whole percentage

    Formats a share, 0 to 1.

  • texturetype booleandefault with two or more parts

    A pattern per part on the bar and each row's key (a hatch; "Other" always has its dots), so no reader depends on hue (WCAG 1.4.1); false turns it off. Always on in forced colours.

  • orderedtype booleandefault false

    The parts have an order (ratings from 1 to 5, age bands): drawn in one hue, from the lightest step of the theme's ramp to the darkest (the reverse in dark mode), five at most; a pinned slot doesn't apply.

  • reftype Ref<HTMLDivElement>

    Ref to the outermost element.

  • idtype string

    The outermost element's id.

Text

  • aria-labeltype string

    Names the list. In a ChartFrame, its title does unless this is given.

  • aria-labelledbytype string

    The id of what names it.

  • aria-describedbytype string

    The id of what describes it.

  • aria-detailstype string

    The id of what gives more about it.

  • labelstype Partial<ChartLabels>

    Words it says. A LabelsProvider sets them for the whole app.

Also accepts the root element's HTML attributes (id, data-*, event handlers).

Spec status

Not part of Material Design 3: a Windmorph Pro component, built on M3's colour roles, type scale, shapes and motion. Its variants and configurations each link to a live example.

  • A bar that prints its shares, with a key below (SegmentedBar)

    Built

    Variant · Parts

  • A thin bar with the parts listed under it (SegmentedList)

    Built

    Variant · List, Ordered

  • More than six parts, folded into "Other"

    Built

    Configuration · Parts

  • Ordered parts in the theme’s ramp (ordered)

    Built

    Configuration · Ordered

  • A pattern per part, on by default (texture)

    Built

    Configuration · Parts, List

  • Amounts in a unit of your own (formatValue)

    Built

    Configuration · List

  • Built on M3’s foundations, for charts

    Extension

    M3 has no charts. The parts take the charts’ colour slots, generated from the theme and checked at 3:1 on every surface, with figures in white or black at 4.5:1, M3’s corner shapes and the spatial spring.

  • Read by pointer, finger and keyboard

    Extension

    The bar is one stop, a native range input over its parts, so a phone’s screen reader steps it too; the pointer and a finger read the part under them in a readout.

Theming & tokens

Set the tokens below on the bar, the list or any ancestor. The parts' colours are the colour slots and ramp every chart shares (--wm-chart-color-1 to --wm-chart-color-8, --wm-chart-step-1 to --wm-chart-step-5 and --wm-chart-quiet for "Other"), and the readout is the core's rich tooltip, themed by its own --md-comp-rich-tooltip-* tokens. className goes on the root. Style each part with classNames: on a bar, strip, body, part, fill, share, legend, legendItem, legendKey, readout, readoutTitle, readoutRow, readoutValue, readoutKey, readoutName; on a list, strip, part, fill, list, row, key, name, share, figure.

SegmentedBar and SegmentedList tokens
VariableDefaultPaints
--wm-segmented-height28pxA segmented bar’s height, tall enough to print a share inside a part.
--wm-segmented-list-height8pxA segmented list’s bar, which prints nothing.
--wm-segmented-cornervar(--md-sys-shape-corner-extra-small)Each part’s corners: every part is its own block.
--wm-segmented-gap2pxThe surface between parts.
--wm-segmented-least-width4pxThe least a part is across, so a sliver still shows.
--wm-segmented-name-colorvar(--md-sys-color-on-surface)A part’s name in a segmented list.
--wm-segmented-share-colorvar(--md-sys-color-on-surface-variant)A part’s share beside its name, quieter than the name and the amount.
--wm-segmented-figure-colorvar(--md-sys-color-on-surface)A part’s amount after its share.
--wm-segmented-list-column-gap12pxIn a segmented list, the space between a row’s key, name, share and amount.
--wm-segmented-list-row-gap8pxIn a segmented list, the space between rows.
--wm-segmented-grow-durationvar(--md-sys-motion-spring-spatial-default-duration)How long the parts take to take their new shares.
--wm-segmented-grow-easingvar(--md-sys-motion-spring-spatial-default-easing)The easing of that change.