• 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

CheckboxList

Controlled group of checkboxes backed by an array value. Renders a labeled form wrapper containing one CheckboxInput per option; the value is the list of selected option ids.

When to use

Use @uxf/ui/checkbox-list to let the user pick multiple options from a fixed list, tracking the selection as an array of ids.

  • Inside a @uxf/form form: use @uxf/form/checkbox-list instead — it registers the field with react-hook-form. Reach for the ui component for a standalone, controlled list.
  • A single boolean: use CheckboxInput.

Usage

import { CheckboxList } from "@uxf/ui/checkbox-list";
import { useState } from "react";

const OPTIONS = [
    { id: "1", label: "Option 1" },
    { id: "2", label: "Option 2" },
    { id: "3", label: "Option 3" },
];

function Example() {
    const [values, setValues] = useState<string[] | null>([]);

    return <CheckboxList label="Pick options" name="options" onChange={setValues} options={OPTIONS} value={values} />;
}

Props

CheckboxList is generic over the option id type: CheckboxList<ValueId extends string | number, Option>. ValueId is inferred from options. Props extend FormControlProps<ValueId[] | null>.

PropTypeDefaultDescription
valueValueId[] | null—Required. Ids of the currently selected options.
onChange(value: ValueId[] | null, event?, ...args) => void—Required. Called with the next selection when an option is toggled, in canonical (sorted) order.
namestring—Required. Field name (shared by all options).
optionsOption[]—Required. Options to render (see below).
labelReactNode—Required. Group label.
helperTextReactNode—Helper/error text for the group.
hasHiddenLabelbooleanfalseVisually hides the group label (kept for screen readers).
isDisabledbooleanfalseDisables the whole group.
isReadOnlybooleanfalseRead-only state for the group.
isInvalidbooleanfalseError state.
isRequiredbooleanfalseMarks the group required.
idstring—Base id (an id is generated with useId when omitted).
classNamestring—Extra class names on the wrapper.

onBlur and onFocus (inherited from FormControlProps) are forwarded to each option.

CheckboxListOption

FieldTypeDescription
idValueId (number | string)Required. Unique option id, stored in value.
labelReactNodeRequired. Option label.
isDisabledbooleanDisables just this option (also disabled when the whole group is).

Exported types: CheckboxListProps, CheckboxListOption, CheckboxListValueId (= number | string).

Note: the group label uses hasHiddenLabel, not hiddenLabel as on CheckboxInput.

Value order

The value is semantically a set, and the emitted array is always sorted by id (normalizeSelectableIds) rather than kept in click order. Rendering is unaffected — the list renders from options, never from the value order.

This matters for react-hook-form: it compares arrays index by index, so a click-ordered value made a form read as dirty after an option was unticked and ticked again. The component can only canonicalize what it emits, so run your defaultValues through the same helper:

const formApi = useForm<FormData>({ defaultValues: { tags: normalizeSelectableIds(data.tagIds) } });

If you submit this value somewhere order-sensitive, note that the payload order changed.

Variants & states

Reflected via classes on the wrapper: isDisabled, isReadOnly, isInvalid, isRequired.

Requirements

Import the component stylesheet once in your global CSS. It renders CheckboxInput (which in turn renders Checkbox), so those stylesheets are required too:

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