Skip to the content

Kongens Nytorv

Metro M1, M2 and M3.

Show on map

The map shows vehicles of the ticked modes only

BusMetroS-tog

Variants and states

RestDisabled
Default
Show on map

The map shows vehicles of the ticked modes only

BusMetroS-tog
Show on map

The map shows vehicles of the ticked modes only

BusMetroS-tog
Default
  • Rest
    Show on map

    The map shows vehicles of the ticked modes only

    BusMetroS-tog
  • Disabled
    Show on map

    The map shows vehicles of the ticked modes only

    BusMetroS-tog

Props

NameTypeDefaultDescription
label*ReactNode—Required. The group's name, in sentence case, a few words or a short question, such as "Show on map": shown above the checkboxes, and the group's accessible name.
hiddenLabelbooleanfalseWhether the label is heard but not seen. Use it where a heading right above already names the group for the eye, so the group keeps its name for the ear.
descriptionReactNode—A line of help under the label about the whole set, such as "The map shows vehicles of the ticked modes only", read after each checkbox's name by a screen reader. Left out, no description is rendered.
errorReactNode—What is wrong with the ticked set and how to put it right, such as "Choose at least one mode". Given, it marks the group invalid and is shown under the checkboxes; left out, the group shows Base UI's own message when its validate fails.
onChange(event: Event, value: string[], details: CheckboxGroup.ChangeEventDetails) => void—Called when a click or Space ticks or unticks a checkbox in the group, or a parent checkbox ticks or unticks the set, with the new list of ticked values as value; details.reason is 'none', and details.cancel() keeps the list as it was. event is details.event. Not called while disabled.
disabledbooleanfalseWhether every checkbox in the group ignores the pointer and the keys. They leave the tab order and take the disabled look, with the label, the description and the error; a fieldset round the group disables it too.
namestring—Identifies the group when a form is submitted: each ticked checkbox submits its value under this name, and a disabled one submits nothing.
children*ReactNode—Required. The group's checkboxes, in reading order: each a Checkbox with its own value, which the group's value lists while it is ticked, and, with allValues, a parent Checkbox first.
classNamestring—Reaches the root, the group. Merged after pn-CheckboxGroup.
styleCSSProperties—Reaches the root, the group.
refRef<HTMLElement>—Reaches the root, the group: the <div role="group">, or the element render gives.
slotProps{ legend?: FieldsetLegendProps | undefined; description?: FieldDescriptionProps | undefined; error?: FieldErrorProps | undefined; }—Props for each part: legend, description, error.
label (required)ReactNode, default —
Required. The group's name, in sentence case, a few words or a short question, such as "Show on map": shown above the checkboxes, and the group's accessible name.
hiddenLabelboolean, default false
Whether the label is heard but not seen. Use it where a heading right above already names the group for the eye, so the group keeps its name for the ear.
descriptionReactNode, default —
A line of help under the label about the whole set, such as "The map shows vehicles of the ticked modes only", read after each checkbox's name by a screen reader. Left out, no description is rendered.
errorReactNode, default —
What is wrong with the ticked set and how to put it right, such as "Choose at least one mode". Given, it marks the group invalid and is shown under the checkboxes; left out, the group shows Base UI's own message when its validate fails.
onChange(event: Event, value: string[], details: CheckboxGroup.ChangeEventDetails) => void, default —
Called when a click or Space ticks or unticks a checkbox in the group, or a parent checkbox ticks or unticks the set, with the new list of ticked values as value; details.reason is 'none', and details.cancel() keeps the list as it was. event is details.event. Not called while disabled.
disabledboolean, default false
Whether every checkbox in the group ignores the pointer and the keys. They leave the tab order and take the disabled look, with the label, the description and the error; a fieldset round the group disables it too.
namestring, default —
Identifies the group when a form is submitted: each ticked checkbox submits its value under this name, and a disabled one submits nothing.
children (required)ReactNode, default —
Required. The group's checkboxes, in reading order: each a Checkbox with its own value, which the group's value lists while it is ticked, and, with allValues, a parent Checkbox first.
classNamestring, default —
Reaches the root, the group. Merged after pn-CheckboxGroup.
styleCSSProperties, default —
Reaches the root, the group.
refRef<HTMLElement>, default —
Reaches the root, the group: the <div role="group">, or the element render gives.
slotProps{ legend?: FieldsetLegendProps | undefined; description?: FieldDescriptionProps | undefined; error?: FieldErrorProps | undefined; }, default —
Props for each part: legend, description, error.

Use it

import { CheckboxGroup } from '@mylder/perron'

Ask your agent

get_reference({ library: "base-ui", component: "CheckboxGroup" })get_reference({ library: "base-ui", component: "Field" })

Keyboard and ARIA

From the Base UI reference for CheckboxGroup, Field and Checkbox, the installed CheckboxGroup and CheckboxRoot, and Fieldset. "From" says who does it. The group adds no keys: each checkbox is a tab stop of its own, as on a native set of checkboxes, since each is an answer of its own, and no roving focus or arrow keys join them.

KeyDoesFrom
Tab, Shift+TabMoves to each checkbox in the group in reading order, and out of the group; skips them all while the group is disabledThe browser, and Base UI's tabIndex
SpaceTicks or unticks the focused checkbox on release, adds its value to the group's list or takes it out, and calls onChange; on a parent checkbox, ticks or unticks the set, as a click doesBase UI, through Checkbox
EnterDoesn't toggle; in a form, clicks the form's default submit buttonBase UI, through Checkbox
ElementRoleAccessible name fromStates announced
rootgroup, from Base UI's CheckboxGrouparia-labelledby, the legend's id, from Fieldset and Base UI: its textNone on the group; it is described, through aria-describedby, by the description and the mounted error
legendNone (generic div, or a span when hidden)None: its text names the rootNone
descriptionNone (paragraph)None: its text describes the root and each checkboxNone
checkboxcheckbox, from CheckboxIts own label, its children, from Checkboxaria-checked, a parent's mixed while some of the set is ticked; a parent's aria-controls, the ids of the boxes it controls; aria-disabled while the group is disabled; aria-invalid while the group is invalid; aria-describedby the description and error
errorNone (generic div, or Base UI's ul for several messages)None: its text describes the root and each checkboxNone: it is read through aria-describedby, never as a live region

What axe won't catch, from the contract, each with how this component meets it:

  • Everything the eye is told, the ear is told, for every shape each prop accepts: the label the eye reads above the set is the group's name, and still is when hidden; the description and the error are the group's and each checkbox's description; each checkbox's tick is its aria-checked, and a parent's dash its aria-checked="mixed", with aria-controls naming the boxes it ticks; the danger edges of an invalid group are its error's words and each checkbox's aria-invalid; the tertiary colour of a disabled group is each checkbox's aria-disabled.
  • Every landmark and named region has an accessible name: the root is a group, not a landmark, and is always named by its legend, since label is required.
  • Every default label can be overridden: none here; CheckboxGroup owns no strings.
  • Every shape the type accepts renders, in every variant: label, description and error each render a string, an element and a list alike, at rest, disabled and invalid; description and error that render nothing leave their part out, by the given helper and by Base UI's Field.Error mounting only with a message.
  • A hidden copy kept for animation is aria-hidden, and a collapsed region is inert: none here; nothing animates or collapses, and the error is unmounted, not hidden, while there is none.
  • Native semantics first: Base UI's role="group" named through aria-labelledby, a <p> for the help, each checkbox Base UI's role="checkbox" with its native hidden input; rendered as a <div>, not a <fieldset>, since Base UI's group renders the element, and Base UI's context, not the browser, disables the checkboxes (Fieldset's CR-5).
  • Focus moves in reading order and returns on close: the legend, the description, the checkboxes in the caller's order, a parent first, then the error, in the DOM and on screen; each checkbox, a parent among them, is one tab stop; the group never moves focus, and nothing in it closes.
  • Every target is at least size.target-min square: the group has no target of its own; each checkbox's row is its target, at least size.target-min square, from Checkbox's CR-9.
  • Loops stop when the system asks for less motion: none here; nothing moves.

Owned strings

No owned strings: every word the group shows or announces comes from the caller, through label, description, error, the validate messages and each checkbox's label, a parent's among them, and each checkbox's state is heard from aria-checked, in the screen reader's own words.

Do and don't

For a caller using the component, with the reason. Each row is a rule: a must row's Don't is never right, a should row's needs a reason, and Checked by says what catches the Don't in a caller's code.

RuleLevelDoDon'tChecked by
DD-1shouldUse CheckboxGroup for several answers to one question that are applied when the form is sent, such as which modes a report coversUse it for filters on the map that take effect at once: those are FilterChips, pressed and seen at oncereview
DD-2mustGive every checkbox a value of its own, and read and set the ticked set through the group's value and onChangeGive the checkboxes checked, defaultChecked or onChange of their own to keep the set: the group's value overrides them, and a box with no value takes the group's namereview
DD-3shouldWrite the legend in sentence case as the question the set answers, "Show on map", and each label as an answer, "Bus"Repeat the legend's words in every label ("Show bus on map"): the screen reader reads the group's name before each box alreadyreview
DD-4shouldGive name so the ticked values reach the form, and connect a form library through its controllerKeep a hidden input of your own for the list: Base UI's hidden inputs already submit each ticked boxreview
DD-5mustSay what is wrong in words, through error or a validate that returns the message, such as "Choose at least one mode"Rely on the checkboxes' danger edges alone: colour is never the only sign (Accessibility)review
DD-6mustUse description for help about the whole set, such as what ticking meansPut help or an error as plain text among the checkboxes: nothing ties it to the group for the earreview
DD-7shouldDisable the whole group with disabled, so every box goes togetherDisable each box by hand in a group that stays enabled: the legend then looks live over dead boxesreview
DD-8mustUse a radio group or a SegmentedControl for one choice among severalUse a CheckboxGroup for one choice: a set of checkboxes says any number may be ticked, none includedreview
DD-9mustPut a parent Checkbox, with parent and no value, first in the group and name it for the set, "All modes", and list every other checkbox's value in allValuesLeave a value out of allValues, or indent the boxes under the parent with a wrapper of your own: the parent counts only what allValues lists, and a wrapper takes the boxes out of the group's columnreview
DD-10shouldUse a single Checkbox for one on-or-off settingWrap one checkbox in a CheckboxGroup: a group of one adds a name the checkbox's own label already givesreview