---
title: Checkbox
---

import LibraryInfo from '@theme/LibraryInfo'
import { Feedback, TokensTable, PropsTable } from '../../src/components'
import { Checkbox } from '@telus-uds/components-web'
import { Checkbox as BaseDocs } from 'docs/@telus-uds/components-base'
import AvailableOnBoth from '../../partials/_platform-considerations-both.mdx'
import NoStylisticVariants from '../../partials/_variants-none.mdx'

# Checkbox

<LibraryInfo figmaLink="https://www.figma.com/embed?embed_host=share&url=https%3A%2F%2Fwww.figma.com%2Ffile%2F4zJn2Qn6uXOqPP1GVDipy6%2F%25F0%259F%258D%2580-Allium-Components%3Fnode-id%3D458%253A457" />

```jsx live
<Checkbox label="This is a checkbox" />
```

## Introduction

Checkbox component represents a checkbox, either isolated or within a form.

[Follow the appropriate instructions](importing-components) to add this component in to your app.

## Guidance

:::caution
In most cases, **[checkbox-group](checkbox-group)** should be used instead of
using Checkbox directly.

Pass the `CheckboxGroup` an `items` array and it will render Checkbox buttons for each item in the
array with appropriate accessibility props, web form tags and state management.
:::

### Controlled version

If the checkbox is controlled from outside, it needs to receive `checked` and `onChange` props.

### Uncontrolled version

In case of uncontrolled checkbox you can use `defaultChecked` prop to provide the initial value.
Whenever the checkbox gets toggled, it calls the `onChange` callback with the new value (boolean).

### Using within forms

You can pass `name` and `value` props if you need a particular checkbox to be a part of a group of
checkboxes on a form.

### Validation and feedback

You can use the `feedback` prop to provide a comment related to the checkbox element. If the comment
is related to a validation error, the checkbox and the feedback can be styled accordingly by setting
the `error` prop to `true` (can also be done without feedback).

### Accessibility

Checkbox component accepts all the common accessibility props, but also sets some defaults, including
accessibility role `'checkbox'` and accessibility state that depends on the other props (`checked`, `inactive`)
or the internal state in case of uncontrolled checkbox.

### Platform considerations

<AvailableOnBoth />

## Props

- Use `label` prop to provide a label for the checkbox.
- For a disabled `Checkbox` set the `inactive` prop to `true`.

<PropsTable base={BaseDocs} />

## Tokens

<TokensTable id="Checkbox" base={BaseDocs} />

## Variants

<NoStylisticVariants />

## Feedback

<Feedback component="Checkbox" />
