Documentation
Checkbox

Checkbox

Displays a boolean value.

Usage

First of all, you need to import the Checkbox component and the useCheckbox hook from the kitchn package.

import { Checkbox, useCheckbox } from "kitchn"

Default

() => {
  const [checked, toggle] = useCheckbox();

  return (
    <Checkbox checked={checked} onChange={toggle}>
      Option
    </Checkbox>
  );
}
Code Editor
() => {
  const [checked, toggle] = useCheckbox();

  return (
    <Checkbox checked={checked} onChange={toggle}>
      Option
    </Checkbox>
  );
}

Checked by default

() => {
  const [checked, toggle] = useCheckbox(true);

  return (
    <Checkbox checked={checked} onChange={toggle}>
      Option
    </Checkbox>
  );
}
Code Editor
() => {
  const [checked, toggle] = useCheckbox(true);

  return (
    <Checkbox checked={checked} onChange={toggle}>
      Option
    </Checkbox>
  );
}

No Label

() => {
  const [checked, toggle] = useCheckbox();

  return (
    <Checkbox checked={checked} onChange={toggle} />
  );
}
Code Editor
() => {
  const [checked, toggle] = useCheckbox();

  return (
    <Checkbox checked={checked} onChange={toggle} />
  );
}

Indeterminate

<Checkbox indeterminate>Option 1</Checkbox>
Code Editor
<Checkbox indeterminate>Option 1</Checkbox>

Disabled

<Container gap={10}>
  <Checkbox disabled>Disabled</Checkbox>
  <Checkbox disabled checked>Disabled Checked</Checkbox>
  <Checkbox disabled indeterminate>Disabled Indeterminate</Checkbox>
</Container>
Code Editor
<Container gap={10}>
  <Checkbox disabled>Disabled</Checkbox>
  <Checkbox disabled checked>Disabled Checked</Checkbox>
  <Checkbox disabled indeterminate>Disabled Indeterminate</Checkbox>
</Container>

Overflowing text

<Checkbox>
  Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum
</Checkbox>
Code Editor
<Checkbox>
  Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum
</Checkbox>

Text styles

<Checkbox style={{ fontSize: 18 }}>
  Arbitrary text styles.
</Checkbox>
Code Editor
<Checkbox style={{ fontSize: 18 }}>
  Arbitrary text styles.
</Checkbox>

Label

() => {
  const [checked, toggle] = useCheckbox()
  return <Checkbox label="Checkbox" checked={checked} onChange={toggle}>Click me</Checkbox>
}
Code Editor
() => {
  const [checked, toggle] = useCheckbox()
  return <Checkbox label="Checkbox" checked={checked} onChange={toggle}>Click me</Checkbox>
}

Full width

<Checkbox fullWidth>
  Areas to the right of this text will be clickable.
</Checkbox>
Code Editor
<Checkbox fullWidth>
  Areas to the right of this text will be clickable.
</Checkbox>