fossui
Components

Checkbox

An on, off, or indeterminate toggle, standalone or in a multi-select group.

A checkbox flips a single option between checked and unchecked, and can also show an indeterminate state. Pass the current value and rebuild in onChanged. Colors, type, and spacing come from the theme. A null onChanged disables it.

import 'package:fossui/fossui.dart';

FossCheckbox(
  value: accepted,
  label: 'Accept terms and conditions',
  onChanged: (checked) => setState(() => accepted = checked),
);

States

value is tristate: true is checked, false is unchecked, and null is indeterminate, which paints a minus glyph. A tap always reports a definite state, so unchecked and indeterminate go to true and checked goes to false. The checkbox never produces null on its own; set value to null yourself to drive the indeterminate state.

FossCheckbox(
  value: null,
  label: 'Some selected',
  onChanged: (checked) => setState(() => all = checked),
);

Label and description

label renders beside the box and description adds a secondary line below it. Both are optional; a bare box with no text is valid.

FossCheckbox(
  value: subscribed,
  label: 'Email notifications',
  description: 'Get a message when someone mentions you.',
  onChanged: (checked) => setState(() => subscribed = checked),
);

Error

A non-null errorText marks the checkbox invalid, recolors the box, and shows a caption below it.

FossCheckbox(
  value: accepted,
  label: 'Accept terms',
  errorText: accepted ? null : 'You must accept to continue',
  onChanged: (checked) => setState(() => accepted = checked),
);

Disabled

Pass a null onChanged, or set enabled: false, to disable the checkbox. It dims to a muted opacity and stops responding to input.

const FossCheckbox(
  value: true,
  label: 'Locked',
  onChanged: null,
);

Groups

For a set of related options, FossCheckboxGroup holds the checked values and one onChanged, and shares them with its FossCheckboxItem children. A tap adds or removes that item's value and reports a new set, never mutating the one you passed.

FossCheckboxGroup<String>(
  label: 'Frameworks',
  values: selected,
  onChanged: (next) => setState(() => selected = next),
  children: const [
    FossCheckboxItem(value: 'next', label: 'Next.js'),
    FossCheckboxItem(value: 'vite', label: 'Vite'),
  ],
);

Set variant: FossCheckboxGroupVariant.card to wrap each option in a full-width, selectable bordered card that tints when checked or hovered.

FossCheckboxGroup<String>(
  values: selected,
  variant: FossCheckboxGroupVariant.card,
  onChanged: (next) => setState(() => selected = next),
  children: const [
    FossCheckboxItem(
      value: 'next',
      label: 'Next.js',
      description: 'React framework',
    ),
    FossCheckboxItem(value: 'vite', label: 'Vite'),
  ],
);

API

FossCheckbox

PropTypeDefaultDescription
valuebool?falseChecked state: true, false, or null for indeterminate.
onChangedValueChanged<bool>?nullCalled with the new definite state on a tap. Null disables it.
labelString?nullTitle beside the box.
descriptionString?nullSecondary line below the label.
errorTextString?nullError caption below the control. A non-null value marks it invalid.
enabledbooltrueWhether it accepts input. Disabled when false or onChanged is null.
styleFossCheckboxStyle?nullPer-instance overrides on the theme.

FossCheckboxGroup

PropTypeDefaultDescription
childrenList<Widget>requiredThe FossCheckboxItem options, each of value type T.
valuesSet<T>{}The set of checked values.
onChangedValueChanged<Set<T>>?nullCalled with the new set when an option is toggled. Null disables the group.
labelString?nullLabel rendered above the options.
errorTextString?nullError caption below the options. A non-null value marks the group invalid.
variantFossCheckboxGroupVariantplainThe visual treatment.
enabledbooltrueWhether the group accepts input.

FossCheckboxItem

PropTypeDefaultDescription
valueTrequiredThe value this option contributes to the group, compared by ==.
labelString?nullTitle beside the box.
descriptionString?nullSecondary line below the label.
enabledbooltrueWhether it accepts input. Disabled when false or the group is disabled.
styleFossCheckboxStyle?nullPer-instance overrides on the theme.

FossCheckboxGroupVariant

plain, card.

Live demo

Open the interactive gallery to try every variant, size, and state with live knobs.

On this page