Search the documentation

Type to search page titles, component names and descriptions.

    Data Entry

    Checkbox, Radio, Select and Switch

    Native choice controls that submit with the form.

    import { Checkbox, CheckboxGroup, RadioGroup, Select, Switch } from 'faifo-design'

    Checkbox, CheckboxGroup, RadioGroup, Select and Switch are native controls with the design system's geometry and states. They submit with an ordinary form and work without JavaScript.

    #When to use

    • Use a Switch for a setting that takes effect as a state (on or off). Use a Checkbox for agreement or for one of several independent options.
    • Use RadioGroup when every option should be visible; use Select when the list is long and the options are familiar.
    • For a list that needs search, use Combobox. For a related record, use RelationPicker.

    #Examples

    Each example is a specimen of the package catalogue, rendered on the server exactly as shown in its code.

    #Selection controls

    Native checkbox, group, radio, switch and select states remain submit-capable.

    Channels
    Delivery
    Record the customer's consent before sending.
    Show codeHide code
    import { Checkbox, CheckboxGroup, RadioGroup, Select, Stack, Switch } from 'faifo-design'
    
    export const Example = () => (
      <Stack
        items={[
          <Checkbox id="priority" name="priority" label="Priority order" value />,
          <CheckboxGroup
            id="channels"
            name="channels"
            label="Channels"
            options={[
              { value: 'email', label: 'Email', checked: true },
              { value: 'sms', label: 'SMS' },
              { value: 'zalo', label: 'Zalo (not connected)', checked: true, disabled: true },
            ]}
          />,
          <RadioGroup
            id="delivery"
            name="delivery"
            label="Delivery"
            value="standard"
            options={[
              { value: 'standard', label: 'Standard' },
              { value: 'express', label: 'Express' },
              { value: 'pickup', label: 'Pickup (closed)', disabled: true },
            ]}
          />,
          <Switch id="notify" name="notify" label="Notify owner" checked />,
          <Switch id="selected-only" name="selected-only" label="Selected" inline />,
          <Switch id="archived-lock" name="archived-lock" label="Archived" checked disabled />,
          <Switch
            id="consent"
            name="consent"
            label="Consent recorded"
            error="Record the customer's consent before sending."
          />,
          <Select
            id="warehouse"
            name="warehouse"
            label="Warehouse"
            value="hn"
            options={[
              { value: 'hn', label: 'Hà Nội' },
              { value: 'hcm', label: 'Hồ Chí Minh' },
            ]}
          />,
        ]}
      />
    )

    #Contract

    #Option groups

    checkbox-group and radio fields (CheckboxGroup, RadioGroup, or RecordForm fields with those types) keep one label above the options at every width, as every field does, each option's text after its control. optionsOrientation sets how the options flow:

    • horizontal (default): options wrap on one line. Use for a few short choices.
    • vertical: one option per line, rendered as data-orientation="vertical" on field-options. Use when the choices should scan as a list, such as companies, branches or job roles.

    Do not restyle field-options in an application to stack options; pass optionsOrientation: 'vertical' instead.

    #API

    Generated from the package source. A property without a description has none in the source yet.

    #CheckboxComponent

    PropertyDescriptionTypeDefault
    idrequired–string–
    namerequired–string–
    labelrequired–string–
    sizeOpt-in matched input/action height: 36px desktop, 44px mobile.'default' | 'large'–
    labelHiddenEmbedded controls share the frame of a compound field.boolean–
    required–boolean–
    disabled–boolean–
    help–string | null–
    span–'half' | 'full'–
    widthHow long the value is: the control is no wider than it needs (FieldFrame).'xs' | 'sm' | 'md'–
    issues–readonly FieldIssue[]–
    error–string | null–
    checked–boolean | 'indeterminate'–
    value–string | boolean–
    submitValue–string–

    #CheckboxGroupComponent

    PropertyDescriptionTypeDefault
    idrequired–string–
    namerequired–string–
    labelrequired–string–
    sizeOpt-in matched input/action height: 36px desktop, 44px mobile.'default' | 'large'–
    labelHiddenEmbedded controls share the frame of a compound field.boolean–
    required–boolean–
    disabled–boolean–
    help–string | null–
    span–'half' | 'full'–
    widthHow long the value is: the control is no wider than it needs (FieldFrame).'xs' | 'sm' | 'md'–
    issues–readonly FieldIssue[]–
    error–string | null–
    value–string | number | boolean | null–
    options–readonly FieldOption[]–
    optionsOrientationHow checkbox-group and radio options flow. horizontal (default) wraps them on a line; vertical lists one option per line under the shared label, for choices whose labels should scan as a column.'horizontal' | 'vertical'–

    #RadioGroupComponent

    PropertyDescriptionTypeDefault
    idrequired–string–
    namerequired–string–
    labelrequired–string–
    sizeOpt-in matched input/action height: 36px desktop, 44px mobile.'default' | 'large'–
    labelHiddenEmbedded controls share the frame of a compound field.boolean–
    required–boolean–
    disabled–boolean–
    help–string | null–
    span–'half' | 'full'–
    widthHow long the value is: the control is no wider than it needs (FieldFrame).'xs' | 'sm' | 'md'–
    issues–readonly FieldIssue[]–
    error–string | null–
    value–string | number | boolean | null–
    options–readonly FieldOption[]–
    optionsOrientationHow checkbox-group and radio options flow. horizontal (default) wraps them on a line; vertical lists one option per line under the shared label, for choices whose labels should scan as a column.'horizontal' | 'vertical'–

    #SelectComponent

    PropertyDescriptionTypeDefault
    idrequired–string–
    namerequired–string–
    labelrequired–string–
    sizeOpt-in matched input/action height: 36px desktop, 44px mobile.'default' | 'large'–
    labelHiddenEmbedded controls share the frame of a compound field.boolean–
    required–boolean–
    disabled–boolean–
    help–string | null–
    span–'half' | 'full'–
    widthHow long the value is: the control is no wider than it needs (FieldFrame).'xs' | 'sm' | 'md'–
    issues–readonly FieldIssue[]–
    error–string | null–
    value–string | number | boolean | null–
    selectionHiddenKeep the selected value accessible while showing only the select chevron.boolean–
    appearance–'default' | 'embedded'–
    placeholder–string | null–
    options–readonly FieldOption[]–

    #SwitchComponent

    PropertyDescriptionTypeDefault
    idrequired–string–
    namerequired–string–
    labelrequired–string–
    sizeOpt-in matched input/action height: 36px desktop, 44px mobile.'default' | 'large'–
    labelHiddenEmbedded controls share the frame of a compound field.boolean–
    required–boolean–
    disabled–boolean–
    help–string | null–
    span–'half' | 'full'–
    widthHow long the value is: the control is no wider than it needs (FieldFrame).'xs' | 'sm' | 'md'–
    issues–readonly FieldIssue[]–
    error–string | null–
    checked–boolean–
    value–string'1'
    inlineKeep the label and control together in compact toolbars, including on mobile.boolean–

    #Types

    #CheckboxProps

    The properties of Checkbox, listed above.

    #ChoiceGroupProps

    The properties of RadioGroup, listed above.

    #SelectProps

    The properties of Select, listed above.

    #SwitchProps

    The properties of Switch, listed above.