• CMSnpm version

    • Overview
    • ContentBuilder
    • InviteUserForm
    • LoginForm
    • RenewPasswordForm
  • UInpm version

    • Overview
    • Accordion
    • AlertBubble
    • AnnouncementBar
    • Avatar
    • AvatarFileInput
    • Badge
    • Button
    • ButtonGroup
    • ButtonList
    • Calendar
    • Checkbox
    • CheckboxButton
    • CheckboxInput
    • CheckboxList
    • Chip
    • ColorRadio
    • ColorRadioGroup
    • Combobox
    • DatePicker
    • DatePickerInput
    • DateRangePicker
    • DateRangePickerInput
    • DatetimePicker
    • DatetimePickerInput
    • Dialog
    • Dropdown
    • Dropzone
    • ErrorMessage
    • FileInput
    • FlashMessages
    • FormComponent
    • Icon
    • IconButton
    • ImageGallery
    • InfoBox
    • Input
    • Label
    • Layout
    • Lightbox
    • ListItem
    • Loader
    • Lozenge
    • Menu
    • Message
    • Modal
    • ✅ ModalDialog
    • ✅ ModalHeader
    • MultiCombobox
    • MultiSelect
    • Pagination
    • Paper
    • Popover
    • Radio
    • RadioGroup
    • RasterImage
    • Select
    • ✅ Tabs
    • TextInput
    • TextLink
    • Textarea
    • TimePicker
    • TimePickerInput
    • Toggle
    • Tooltip
    • Typography
  • Formnpm version

    • Overview
    • AvatarFileInput
    • CheckboxButton
    • CheckboxInput
    • CheckboxList
    • ColorRadioGroup
    • Combobox
    • DatePickerInput
    • DateRangePickerInput
    • DatetimePickerInput
    • Dropzone
    • FileInput
    • Form
    • FormRenderer
    • GpsInput
    • MoneyInput
    • MultiCombobox
    • MultiSelect
    • NumberInput
    • PasswordInput
    • RadioGroup
    • Select
    • TextInput
    • Textarea
    • TimePickerInput
    • Toggle
  • DataGridnpm version

    • Overview
    • DataGrid
    • DataGridCustomExample
    • ExportButton
    • FilterList
    • Filters
    • FiltersButton
    • FulltextInput
    • HiddenColumns
    • HiddenColumnsButton
    • Pagination
    • RowCounts
    • RowsPerPageSelect
    • SelectedRowsToolbar
    • TableV2
    • ToolbarControl
    • ToolbarCustoms
    • ToolbarTabs
  • Wysiwygnpm version

    • Overview
  • Resizernpm version

    • Overview
  • Routernpm version

    • Overview
  • Corenpm version

    • Overview
  • Core-Reactnpm version

    • Overview
  • Stylesnpm version

    • Overview
  • Localizenpm version

    • Overview
  • Analyticsnpm version

    • Overview
  • Datepickernpm version

    • Overview
  • Icons-generatornpm version

    • Overview
  • Smart-addressnpm version

    • Overview
  • E2Enpm version

    • Overview
  • E2E-Playwrightnpm version

    • Overview
View source on GitLab

Checkbox

Controlled checkbox primitive. Renders a <div role="switch"> that shows a check icon when selected (or a minus icon when indeterminate).

When to use

Use Checkbox as a low-level, controlled control when you render your own label and layout — it has no built-in label element.

  • Labeled field: use CheckboxInput, which wraps Checkbox with a label and helper/error text.
  • Group of related options: use CheckboxList.
  • Inside a @uxf/form form: use @uxf/form/checkbox-input, which registers the field with react-hook-form. There is no @uxf/form/checkbox twin.

Usage

import { Checkbox } from "@uxf/ui/checkbox";
import { useState } from "react";

function Example() {
    const [checked, setChecked] = useState(false);
    const onChange = (value: boolean | undefined) => setChecked(value ?? false);

    return <Checkbox name="terms" onChange={onChange} value={checked} />;
}

Props

Extends FormControlProps<boolean | undefined>, which supplies the shared controlled-field props (value, onChange, name, onBlur, onFocus, isDisabled, isFocused, isReadOnly, isInvalid, isRequired).

Prop Type Default Description
value boolean | undefined — Required. Checked state.
onChange (value: boolean | undefined, event?, ...args) => void — Required. Called with the toggled value when the control is clicked.
name string — Required. Field name.
size CheckboxSize "default" Size (see below).
indeterminate boolean false Shows the minus icon instead of the check icon.
renderContent (className: string, checked: boolean | undefined) => ReactNode — Renders custom inner content in place of the default icon.
isDisabled boolean false Non-interactive; removes pointer events.
isReadOnly boolean false Prevents value changes and removes the control from the tab order.
isInvalid boolean false Error state (aria-invalid).
isRequired boolean false Marks the control required (aria-required).
isFocused boolean false Forces the focus indicator.
onBlur, onFocus FocusEventHandler — Focus handlers.
id string — Element id.
className string — Extra class names.
style CSSProperties — Inline styles.

Variants & states

Sizes (from theme.ts):

Group Values
size default, lg

CheckboxSizes is an open interface, so a project can add its own sizes via module augmentation:

declare module "@uxf/ui/checkbox/theme" {
    interface CheckboxSizes {
        sm: true;
    }
}

Behavioural states are reflected via classes and driven by the props above: selected (value), indeterminate, isDisabled, isReadOnly, isInvalid, isFocused.

Requirements

Import the component stylesheet once in your global CSS:

@import url("@uxf/ui/css/checkbox.css");

Also requires the global @uxf/ui token layer, set up once per app — see @uxf/ui setup.

Default
Open in new tab