Segmented bar
ProOne 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.
Keyboard
| Key | Action | Where |
|---|---|---|
| Arrow Right or Arrow Up | Reads the next part.SegmentedBar | SegmentedBar |
| Arrow Left or Arrow Down | Reads the part before.SegmentedBar | SegmentedBar |
| Home or End | Reads the first or the last part.SegmentedBar | SegmentedBar |
| Page Up or Page Down | Moves a tenth of the parts, at least one: with six parts or fewer, one part.SegmentedBar | SegmentedBar |
| Escape | Hides the readout, wherever focus is for one the pointer shows. It shows again on another part (a key or the pointer), once the pointer leaves and comes back, or when the bar takes focus again. With no readout showing, Escape goes on, so a dialog round the bar still closes.SegmentedBar | SegmentedBar |
- Right to left, Arrow Left reads the next part and Arrow Right the one before, as the parts run from the right.
- Tabbing to the bar reads its first part and shows the readout, and the keys start there; after a press or a tap they go on from the part pressed.
SegmentedListhas no keys: its rows are text, with nothing to focus.
Screen reader
- Role
SegmentedBar: aslider(a native range input, unseen, over the parts), then the key, a list namedlabels.parts("Parts") and the bar’s name.SegmentedList: a list, one item per part.- Accessible name
- Named by
aria-labeloraria-labelledby, or in aChartFrameby its title; a development build warns about one with no name. - States announced
- The slider’s value text (
aria-valuetext) is the part it reads, then where it is among the parts: "Phone: 5,120, 59%, 1 of 3", fromlabels.describePart. With no parts it sayslabels.noValue("No value") and isaria-disabled, still focusable, so focus on it never drops to the page. Each list row reads its name, share and amount apart ("Web, 60%, 600").
- The blocks, the shares printed on them, the colour keys and the readout are hidden from assistive tech (
aria-hidden); the value text, the key's names and the list's rows say the same. - A screen reader's step (a swipe up or down, or a volume key) moves the slider as a key does, since it is a native input.
- An amount that isn’t a number reads
labels.noValue, never "NaN". - The value text follows the keys and a screen reader’s own steps, never the pointer hovering a focused bar.
Focus
- A
SegmentedBaris one tab stop. Keyboard focus draws the M3 focus indicator round the bar and shows the readout of the part it reads. - A press or a tap on a part reads it and moves focus to the bar, without scrolling, so the arrow keys go on from that part.
- A
SegmentedListadds no tab stops.
Touch target
- The bar is 28px tall (
--wm-segmented-height), under 48px: it is read, never pressed to act, and a finger can slide along it. Everything it shows is also in the key, the value text and a frame's table view; raise the token where fingers need a taller bar. - A
SegmentedListhas nothing to press.
Motion
- The parts grow to their shares when the bar first comes into view, and move to new shares when they change, on the default spatial spring. Under reduced motion they take their shares at once.
- While one part is read the others step back, dimming their colour on the fast effects spring, under reduced motion too: a fade is not movement.
- A bar on screen as the page hydrates shows its shares from the server's HTML and doesn't replay.
What you need to do
- Name each bar or list with
aria-label("Visits by device"), or put it in aChartFrame, whose title names it. - Keep to two to five parts, largest first, so anything past six folds the smallest into "Other". Labels are text, never HTML.
- Use
orderedonly for parts with an order, and keep them to five. - Keep
textureon (it is, for two or more parts) where colour may not be told apart; the key names every part either way. - In forced-colours mode the patterns are always drawn: each part is
Canvaswith aCanvasTextedge and its pattern inCanvasText(the first slot or step a solidCanvasTextblock, "Other" dotted), a share printed on a part sits on aCanvaspatch, and the colour keys (in the key, the readout and aSegmentedList’s rows) carry the same patterns, so a part is matched to its name without colour. - Translate
labels.describePart,labels.parts,labels.other,labels.noValue,labels.listSeparator(what screen readers hear between aSegmentedListrow’s name, share and amount, ", " by default) and the table view’s column headers (labels.part,labels.amountandlabels.share), or set them once for the app with aLabelsProvider(itsChartwords).