• 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

CheckboxInput

Controlled checkbox with a label and optional helper/error text. Wraps Checkbox inside a Headless UI Switch group.

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).

Prop Type Default Description
value boolean | undefined — Required. Checked state.
onChange (value: boolean | undefined, event?, ...args) => void — Required. Called with the toggled value.
name string — Required. Field name.
label ReactNode — Required. Label content.
helperText ReactNode — Text shown under the label (used for the error message).
hiddenLabel boolean false Visually hides the label (kept for screen readers).
indeterminate boolean false Shows the indeterminate (minus) icon.
size CheckboxSize "default" Checkbox size (default, lg).
isDisabled boolean false Non-interactive state.
isReadOnly boolean false Prevents value changes.
isInvalid boolean false Error state (links helperText to the control via an error id).
isRequired boolean false Marks the field required.
isFocused boolean false Forces the focus indicator.
onBlur, onFocus FocusEventHandler — Focus handlers.
id string — Element id (an id is generated with useId when omitted).
className string — Extra class names on the wrapper.
style CSSProperties — 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