Shadcn UI Checkbox

Add checkboxes with ShadCheckbox and ShadCheckboxFormField; label, sublabel, form validation. Use when adding boolean toggles or terms acceptance in a Flutter shadcn_ui app or ShadForm.

serverpod 0d0c0c0 1.1 KB Updated

File contents

Shadcn UI — Checkbox

Instructions

ShadCheckbox is a control that toggles between checked and unchecked. Use value and onChanged; optional label and sublabel. For forms use ShadCheckboxFormField with id, validator, and form state.

Standalone

ShadCheckbox(
  value: value,
  onChanged: (v) => setState(() => value = v),
  label: const Text('Accept terms and conditions'),
  sublabel: const Text(
    'You agree to our Terms of Service and Privacy Policy.',
  ),
)

Form field

ShadCheckboxFormField(
  id: 'terms',
  initialValue: false,
  inputLabel: const Text('I accept the terms and conditions'),
  onChanged: (v) {},
  inputSublabel: const Text('You agree to our Terms and Conditions'),
  validator: (v) {
    if (!v) return 'You must accept the terms and conditions';
    return null;
  },
)

serverpod/skills-registry/tree/main/skills/shadcn_ui/shadcn_ui-checkbox commit 0d0c0c0a1b

Frequently asked questions

npx skillmds@latest add serverpod/shadcn-ui-checkbox