Fidely UI v1 beta is now available!. 🚀

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
checkedboolean—Controls the checked state of the switch (for controlled usage).
defaultCheckedbooleanfalseSets the initial checked state (for uncontrolled usage).
onCheckedChange(checked: boolean) => void—Callback fired when the switch state changes.
requiredbooleanfalseMarks the switch as required in a form.
disabledbooleanfalseDisables interaction with the switch.
namestring—The 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.
childrenReactNode—The content of the switch, typically including control, thumb, and label.
asReact.ElementType—The content of the switch, typically including control, thumb, and label.

Control

PropTypeDefaultDescription
childrenReactNode—Contains the visual parts of the switch (usually the Thumb).

Indicator

PropTypeDefaultDescription
childrenReactNode—Optional custom checkbox icon.

Label

PropTypeDefaultDescription
childrenReactNode—The label text displayed beside the switch.

HiddenInput

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

On this page