Unlock faster development with Fidely UI Pro components Coming soon

Checkbox

A control element that allows for multiple selections within a set.

Usage

import { Checkbox } from '@fidely-ui/react'
<Checkbox.Root>
  <Checkbox.HiddenInput />
  <Checkbox.Control>
    <Checkbox.Indicator />
  </Checkbox.Control>
  <Checkbox.Label />
</Checkbox.Root>

Examples

With custom icon

Use your own custom checked icon by wrapping the Checkbox.Indicator

Sizes

Pass the size prop to the Switch.Root component to change the size of the switch component.

Colors

Pass the colorPalette prop to the Switch.Root component to change the color of the component.

Controlled

Use the checked and onCheckedChange props to control the state of the switch.

Disabled States

Pass the disabled prop to the Checkbox.Root component to disabled the checkbox.

Props

Root

PropTypeDefaultDescription
checkedbooleanControls the checked state of the switch (for controlled usage).
defaultCheckedbooleanfalseSets the initial checked state (for uncontrolled usage).
onCheckedChange(checked: boolean) => voidCallback fired when the switch state changes.
requiredbooleanfalseMarks the switch as required in a form.
disabledbooleanfalseDisables interaction with the switch.
namestringThe name of the switch input for form submission.
valuestring"on"The value of the switch input when checked.
size"sm" | "md" | "lg""md"Controls the size of the switch.
colorPalette"red" | "blue" | "green" | "purple" | "orange" | "gray""blue"Sets the color palette of the switch.
childrenReactNodeThe content of the switch, typically including control, thumb, and label.
asReact.ElementTypeThe content of the switch, typically including control, thumb, and label.

Control

PropTypeDefaultDescription
childrenReactNodeContains the visual parts of the switch (usually the Thumb).

Indicator

PropTypeDefaultDescription
childrenReactNodeOptional custom checkbox icon.

Label

PropTypeDefaultDescription
childrenReactNodeThe label text displayed beside the switch.

HiddenInput

PropTypeDefaultDescription
namestringThe name of the hidden input field.
valuestring"on"The value of the hidden input when the switch is checked.

On this page