• 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

CheckboxInput

Controlled checkbox with a label and optional helper/error text. A plain composition of the visual Checkbox and a <label> — no headless primitive is involved; clicking the label toggles the value directly, unless the control is disabled or read-only.

When to use

Use @uxf/ui/checkbox-input for a labeled checkbox that you control yourself (you own value / onChange).

  • Inside a @uxf/form form: use @uxf/form/checkbox-input instead — it registers the field with react-hook-form, derives the invalid state from validation, and renders the validation message. Reach for the ui component only for a standalone, controlled checkbox outside a form.
  • Just the box, no label: use Checkbox.
  • Several related options: use CheckboxList.

Usage

import { CheckboxInput } from "@uxf/ui/checkbox-input";
import { useState } from "react";

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

    return <CheckboxInput label="I agree" name="agree" onChange={onChange} value={checked} />;
}

Props

Extends FormControlProps<boolean | undefined> (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.
namestring—Required. Field name.
labelReactNode—Required. Label content.
helperTextReactNode—Text shown under the label (used for the error message).
hiddenLabelbooleanfalseVisually hides the label (kept for screen readers).
indeterminatebooleanfalseShows the indeterminate (minus) icon.
sizeCheckboxSize"default"Checkbox size (default, lg).
isDisabledbooleanfalseNon-interactive state.
isReadOnlybooleanfalsePrevents value changes.
isInvalidbooleanfalseError state (links helperText to the control via an error id).
isRequiredbooleanfalseMarks the field required.
isFocusedbooleanfalseForces the focus indicator.
onBlur, onFocusFocusEventHandler—Accepted (inherited from FormControlProps) but not forwarded anywhere by this component.
idstring—Element id (an id is generated with useId when omitted).
classNamestring—Extra class names on the wrapper.
styleCSSProperties—Inline styles on the wrapper.

Variants & states

Size accepts default and lg, forwarded to the underlying Checkbox. The wrapper reflects isDisabled, isReadOnly, isInvalid and isRequired as state classes.

This component does not validate on its own — pass isInvalid and helperText yourself, or use the @uxf/form/checkbox-input twin, which fills them from the form state.

Requirements

Import the component stylesheet once in your global CSS. It renders a Checkbox, so that stylesheet is required too:

@import url("@uxf/ui/css/checkbox-input.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