Skip to main content

CheckboxGroup

Allows a user to select one or multiple items from a list.

Submit feedback
github
import { CheckboxGroup } from '@uhg-abyss/mobile';
    () => {
    const [value, setValue] = useState([]);
    const handlePress = () => {
    console.log(value);
    };
    return (
    <Layout.Stack grow>
    <CheckboxGroup align="left" value={value} onChange={(value) => setValue(value)}>
    <CheckboxGroup.SelectAll label='Select All'/>
    <Checkbox label="Option 1" value="one" />
    <Checkbox label="Option 2" value="two" />
    <Checkbox label="Option 3" value="three" />
    <Checkbox label="Option 4" value="four" />
    <Checkbox label="Option 5" value="five" />
    </CheckboxGroup>
    <Button size='small' onPress={handlePress}>Submit</Button>
    </Layout.Stack>
    );
    };

    Using the useForm hook allows you to manage the state of the checkbox group more effectively, especially when dealing with forms.

    useState

    Using the useState hook gets values from the component state.

    Value

    Checkboxes within a CheckboxGroup component require the value prop to be specified in order to function as part of the checkbox group.

    Select All

    Use the CheckboxGroup.SelectAll component to control the checked state for the entire group.

    Disabled

    Use the isDisabled prop to disable the entire group.

    Align

    The align prop determines which side the checkbox is on for the entire group. 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.

    Multi Select Card

    A child component can be used instead of a traditional checkbox label. The label prop is removed and a component is added as a child of each checkbox.

    See Card for more details on the Card used below.

    CheckboxGroup Props

    Prop NameTypeDefaultDescription
    align"left" | "right-The side the checkboxes in the group will be aligned to
    childrennode-The contents of the checkbox group component
    hideLabelbooleanfalseFlag to hide label
    isDisabledbooleanfalseFlag to enable/disable the checkboxes. If true, all checkboxes will be disabled
    onChangefunction-Callback fired every time the value changes
    valuearray-Array that holds the checkbox value when the isChecked prop set to true

    CheckboxGroup.SelectAll Props

    Prop NameTypeDefaultDescription
    childrennode-The contents of the SelectAll component
    labelstringSelect AllLabel of the SelectAll checkbox

    CheckboxGroup.SelectAll Classes

    Class NameDescription
    abyss-checkbox-group-select-all-checkboxSelect All checkbox element
    abyss-checkbox-group-select-all-rootSelect All checkbox root element
    Table of Contents