Skip to main content

Checkbox

Used to mark an option as true/checked or false/not checked

Submit feedback
github
import { Checkbox } from '@uhg-abyss/mobile';
    () => {
    const [isChecked, setChecked] = useState(true);
    return (
    <Checkbox
    label="I agree"
    isChecked={isChecked}
    onChange={setChecked}
    />
    );
    };

    States

    • Default - The default checkbox is unchecked.
    • Checked - Use the isChecked prop to mark a checkbox as checked.
    • Indeterminate - Use the isIndeterminate prop to set the checkbox as indeterminate.
    • Disabled - Use the isDisabled prop to disable a checkbox. A disabled checkbox is unusable and un-clickable.
    • Help Text - Use the helpText prop to insert helpful text below the checkbox.
    • Error Message - Use the errorMessage prop to display a custom error message below the checkbox.

    Using the useForm hook allows you to easily manage form state and validation.

    useState

    Using the useState hook gets values from the component state.

    Align

    The align prop determines which side the checkbox is on. The options are left or right. When the align prop is set to right, the label stays on the left and only the checkbox is set to the rightmost edge of it's container. The default is left.

    Checkbox Props

    Prop NameTypeDefaultDescription
    align"left" | "rightleftThe side the checkbox should be aligned to
    childrennode-The contents of the checkbox component
    errorMessagestring-Set the error message displayed below the checkbox
    helpTextstring-Set the subtext displayed below the checkbox
    hideLabelbooleanfalseFlag to hide label
    isCheckedbooleanfalseFlag to turn checkbox on or off
    isDisabledbooleanfalseFlag to enable/disable the checkbox. If true, the checkbox will be disabled
    isIndeterminatebooleanfalseSet the checkbox to indeterminate or not
    labelstring-Label of the checkbox
    onChangefunction-Callback fired every time the value changes
    valuestring-Value of the checkbox

    Checkbox Classes

    Class NameDescription
    abyss-checkboxCheckbox element
    abyss-checkbox-error-containerCheckbox error container element
    abyss-checkbox-error-iconError icon element
    abyss-checkbox-error-labelText element in the error container
    abyss-checkbox-help-textText element below the label
    abyss-checkbox-labelLabel element
    abyss-checkbox-label-containerLabel container
    abyss-checkbox-rootCheckbox root element

    Dynamic Type

    The checkbox icon scales up to 3XL, while any text passed in scales according to Abyss dynamic type standards.

    Checkbox Tokens

    Token NameValue
    checkbox.color.icon
    #FFFFFF
    checkbox.color.surface.container.enabled.default
    #FFFFFF
    checkbox.color.surface.container.enabled.selected
    #196ECF
    checkbox.color.surface.container.disabled.default
    #CBCCCD
    checkbox.color.surface.container.disabled.selected
    #929496
    checkbox.color.border.container.enabled.default
    #929496
    checkbox.color.border.container.disabled.default
    #929496
    checkbox.border-radius.all.container
    4
    checkbox.border-width.all.container
    2
    checkbox.sizing.all.container
    20
    checkbox.sizing.all.icon
    20
    Table of Contents