Skip to content
Vy logo
  • Spor
  • Resources
Components

Checkbox

Use Checkbox when the user needs multiple checked options or accepting terms.

FigmaGitHub

Code examples

<Checkbox>
  I like trains
</Checkbox>

Guidelines

There are some things that are recommended when using checkboxes:

  • Use checkboxes when users can select multiple options.
  • If there are many options, consider using a select menu or combobox instead of checkboxes.
  • Arrange checkboxes vertically rather than horizontally to improve readability and scanning.
  • Order options alphabetically when all options are equally relevant.
  • Avoid disabled checkboxes. Consider removing the option instead, or give an explanation to why the option is disabled.

Code

<Checkbox />

import { Checkbox } from "@vygruppen/spor-react";

A checkbox

Props

Name
Type
Required?
Description
checkedboolean
defaultCheckedboolean
disabledboolean
invalidboolean
onCheckedChange(details: CheckedChangeDetails) => voidCallback for when the checkbox changes
valuestringThe returned value
formstringThe id of the form that the checkbox belongs to.
idstringThe unique identifier of the machine.
idsPartial<{ root: string hiddenInput: string control: string label: string }>The ids of the elements in the checkbox. Useful for composition.
namestringThe name of the input field in a checkbox. Useful for form submission.
readOnlyboolean
requiredboolean

<CheckboxGroup />

import { CheckboxGroup } from "@vygruppen/spor-react";

Groups Checkbox components

Props

Name
Type
Required?
Description
defaultValuestring[]Array of initially checked values
onCheckedChangefunctionCallback for when the checkbox selection changes
disabledboolean
direction"row" | "column" | "row-reverse" | "column-reverse"Default "row"
gapstring | numberSpace between checkboxes. Default is 1