React Native / Inputs
Checkbox
Checkbox with its label. The whole row is the touch target (at least 44pt high).
import { Checkbox } from "@stylhero/native";
Example
import { useState } from "react";
import { Checkbox } from "@stylhero/native";
function CheckboxExample() {
const [agree, setAgree] = useState(false);
return <Checkbox label="Include used parts" description="From sellers rated 4 stars or more" checked={agree} onChange={setAgree} />;
}
Props
| Prop | Type | Default | Description |
|---|---|---|---|
checked required |
boolean | "mixed" |
- | "mixed" shows a dash, e.g. for "select all" when only some rows are selected. |
label required |
string |
- | |
onChange required |
(checked: boolean) => void |
- | Called with the new value. From "mixed" a press checks the box. |
description |
string |
- | |
disabled |
boolean |
- | |
error |
string |
- | Error message. Turns the box red and is read with the checkbox. |
ref |
Ref<ComponentRef<typeof View>> |
- | |
style |
StyleProp<ViewStyle> |
- | |
testID |
string |
- |
Screen reader gestures
| Gesture (VoiceOver / TalkBack) | Does |
|---|---|
| Double-tap | Toggles it |
Accessibility
- A checkbox, read as checked, not checked or mixed.
descriptionanderrorare its hint. - The whole row (control, label and description) is one touch target and is read as one element.
Generated from src/components/Checkbox.tsx. Something wrong or missing? Open an issue.