Skip to content

Checkbox

const Checkbox: ForwardRefExoticComponent<CheckboxProps & RefAttributes<CheckboxHandle>>;

Toggle checkbox with label. Activated via Space or Enter.

const [agreed, setAgreed] = useState(false);
<Checkbox
checked={agreed}
onChange={setAgreed}
label="I agree to the terms"
focusedStyle={{ bg: "cyan", color: "black" }}
/>

PropertyTypeDescription
checkedbooleanWhether the checkbox is checked
checkedChar?stringCustom character for checked state (default: ”✓”)
disabled?booleanWhether the checkbox is disabled
focusedStyle?StyleStyle when focused
label?stringLabel text displayed next to the checkbox
onChange(checked) => voidCalled when the checkbox is toggled
style?StyleStyle for the checkbox container
uncheckedChar?stringCustom character for unchecked state (default: ” “)

Handle for Checkbox — exposes checked state

blur(): void;

Programmatically blur (unfocus) this element

void

FocusableHandle.blur


focus(): void;

Programmatically focus this element

void

FocusableHandle.focus


scrollIntoView(options?): void;

Scroll the nearest parent ScrollView to make this element visible. Behaves like the DOM Element.scrollIntoView() method. No-op if the element is not inside a ScrollView.

ParameterTypeDescription
options?ScrollIntoViewOptionsAlignment options (default: { block: "nearest" })

void

const inputRef = useRef<InputHandle>(null);
// Minimal scroll — just enough to make it visible
inputRef.current?.scrollIntoView();
// Center the element in the viewport
inputRef.current?.scrollIntoView({ block: "center" });

FocusableHandle.scrollIntoView

PropertyModifierTypeDescriptionInherited from
checkedreadonlybooleanWhether the checkbox is currently checked-
isFocusedreadonlybooleanWhether this element is currently focusedFocusableHandle.isFocused