Forms

Checkbox

An accessible checkbox component with support for labels, descriptions, and indeterminate state. Essential for consent forms, preferences, and eligibility selections in healthcare applications.

Basic Usage

Simple checkboxes for consent forms and user preferences. Always provide clear, descriptive labels.

With Description

Use descriptions to provide additional context about what the checkbox means. This is especially important for legal and medical consent forms.

Indeterminate State

Use indeterminate state when some but not all items in a group are selected. Common in eligibility checklists and multi-select scenarios.

Disabled State

Disable checkboxes when options are not available or have already been set. Provide context about why the option is disabled.

Validation

Use the error prop to display validation messages. Use validateOnMount to show errors immediately.

Sizes

Choose the appropriate size based on context. Use larger checkboxes for important consent forms and smaller ones for compact lists.

Props

PropTypeDefaultDescription
id stringUnique identifier for the checkbox
name stringForm field name
value stringValue attribute for form submission
label stringLabel text for the checkbox (required)
checked booleanfalseWhether the checkbox is checked
description stringDescription text below the label
required booleanfalseWhether the checkbox is required
disabled booleanfalseWhether the checkbox is disabled
error stringError message to display
indeterminate booleanfalseIndeterminate state (partially checked)
size 'sm' | 'md' | 'lg''md'Size of the checkbox
class stringAdditional CSS classes
onchange (event: Event) => voidChange handler
testId stringTest ID for e2e testing (Playwright, Cypress)
validateOnMount booleanfalseShow validation state immediately without waiting for interaction

Healthcare Best Practices

  • • Always use required prop for HIPAA consent checkboxes and other legally required acknowledgments
  • • Provide clear descriptions for consent forms explaining what the patient is agreeing to
  • • Use error prop to display validation messages for required checkboxes before form submission
  • • Use indeterminate state for "select all" functionality in eligibility checklists and multi-step forms
  • • Disable checkboxes that have already been set or are not applicable, but provide context via descriptions
  • • Ensure all consent checkboxes are clearly labeled and cannot be pre-checked (must be explicitly opted-in)
  • • Use larger sizes for critical consent forms to ensure they are easily readable and accessible
  • • Always validate required checkboxes on the server side, not just client side