• CMSnpm version

    • Overview
    • ContentBuilder
    • InviteUserForm
    • LoginForm
    • RenewPasswordForm
    • WysiwygInput
  • 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
    • Switch
    • ✅ 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
  • DnDnpm 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).

PropTypeDefaultDescription
valueboolean | undefined—Required. Checked state.
onChange(value: boolean | undefined, event?, ...args) => void—Required. Called with the toggled value when the control is clicked.
namestring—Required. Field name.
sizeCheckboxSize"default"Size (see below).
indeterminatebooleanfalseShows 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.
isDisabledbooleanfalseNon-interactive; removes pointer events.
isReadOnlybooleanfalsePrevents value changes and removes the control from the tab order.
isInvalidbooleanfalseError state (aria-invalid).
isRequiredbooleanfalseMarks the control required (aria-required).
isFocusedbooleanfalseForces the focus indicator.
onBlur, onFocusFocusEventHandler—Focus handlers.
idstring—Element id.
classNamestring—Extra class names.
styleCSSProperties—Inline styles.

Variants & states

Sizes (from theme.ts):

GroupValues
sizedefault, 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
States
Open in new tab