Checkbox API

API documentation for Checkbox component

Checkbox#

Props#

Defines valid properties in CheckboxRoot component.

nametypedefaultdescription
refRef<unknown>
null
The reference to the component instance.
pIfboolean
true
Whether the component should be rendered.
styleCSSProperties | ((instance?: CheckboxRootInstance) => CSSProperties)
null
The style to apply to the component.
classNamestring | ((instance?: CheckboxRootInstance) => string)
null
The class name to apply to the component.
asstring | number | bigint | boolean | ComponentClass<any, any> | FunctionComponent<any> | ReactElement<unknown, string | JSXElementConstructor<any>> | Iterable<ReactNode, any, any> | ReactPortal | Promise<AwaitedReactNode>
null
The component type to render.
asChildboolean
false
Whether the component should be rendered as a child component.
ptSafeRecord<CheckboxRootPassThrough>
null
The pass-through props to pass to the component
ptOptionsPassThroughOptions
null
The pass-through options to pass to the component
unstyledboolean
null
Whether the component should be rendered without classes.
dtunknown
null
The design token to use for the component.
stylesStylesOptions<ComponentInstance>
null
The styles to use for the component.
childrenReactNode | ((instance: CheckboxRootInstance) => ReactNode)
null
The children to render.
valueunknown
null
Value of the checkbox.
namestring
null
The name of the checkbox.
size"small" | "large" | "normal"
null
Defines the size of the checkbox.
variant"outlined" | "filled"
null
Specifies the input variant of the component.
disabledboolean
false
When present, it specifies that the element should be disabled.
readOnlyboolean
false
When present, it specifies that an input field is read-only.
requiredboolean
false
When present, it specifies that the element is required.
invalidboolean
false
When present, it specifies that the component should have invalid state style.
inputIdstring
null
Identifier of the underlying input element.
inputStyleCSSProperties
null
Inline style of the input field.
inputClassNamestring
null
Style class of the input field.
ariaLabelstring
null
Establishes a string value that labels the component.
ariaLabelledbystring
null
Establishes relationships between the component and label(s) where its value should be one or more element IDs.
onFocus(event: FocusEvent<HTMLInputElement>) => void
null
Callback function that is called when the checkbox is focused.
onBlur(event: FocusEvent<HTMLInputElement>) => void
null
Callback function that is called when the checkbox loses focus.
onCheckedChange(event: CheckboxRootChangeEvent) => void
null
Callback fired when the checkbox's checked state changes.
checkedboolean
null
When present, it specifies the input's checked state.
defaultCheckedboolean
null
The default value for the input when not controlled by `checked` and `onCheckedChange` .
indeterminateboolean
false
When present, it specifies input state as indeterminate.
trueValuestring | number | boolean
true
Value in checked state.
falseValuestring | number | boolean
false
Value in unchecked state.
[key: string]any
null
pt-{optionName}-*-
null
Pass through attributes for customizing component. For more info, see Pass Through tab.

State#

Defines valid state in CheckboxRoot component.

nametypedefaultdescription
checkedboolean
null
The checked state of the useCheckbox.
indeterminateboolean
null
The indeterminate state of the useCheckbox.

Exposes#

Defines the methods and properties exposed by CheckboxRoot component.

nametypedefaultdescription
stateuseCheckboxState
null
The state of the useCheckbox.
onChange(event: useCheckboxChangeEvent) => void
null
Callback fired when the useCheckbox's checked state changes.

Events#

Event fired when the checkbox's checked state changes.

nametypedescription
valueunknownValue of the checkbox.
originalEventChangeEventThe original event that triggered the change.
checkedbooleanThe checked state of the checkbox.

Interfaces#

Defines passthrough(pt) options of CheckboxRoot component.

nametypedefaultdescription
rootCheckboxRootPassThroughType<HTMLAttributes<HTMLDivElement>>
null
Used to pass attributes to the root's DOM element.
inputCheckboxRootPassThroughType<InputHTMLAttributes<HTMLInputElement>>
null
Used to pass attributes to the input's DOM element.
boxCheckboxRootPassThroughType<HTMLAttributes<HTMLDivElement>>
null
Used to pass attributes to the box's DOM element.
iconCheckboxRootPassThroughType<HTMLAttributes<HTMLSpanElement>>
null
Used to pass attributes to the icon's DOM element.

Types#

Instance of CheckboxRoot component.

values
ComponentInstance<CheckboxRootProps, CheckboxRootState, CheckboxRootExposes>

useCheckbox#

Props#

Defines valid properties in useCheckbox.

nametypedefaultdescription
checkedboolean
null
When present, it specifies the input's checked state.
defaultCheckedboolean
null
The default value for the input when not controlled by `checked` and `onCheckedChange` .
indeterminateboolean
false
When present, it specifies input state as indeterminate.
trueValuestring | number | boolean
true
Value in checked state.
falseValuestring | number | boolean
false
Value in unchecked state.
onCheckedChange(event: useCheckboxChangeEvent) => void
null
Callback fired when the checkbox's checked state changes.

State#

Defines valid state in useCheckbox.

nametypedefaultdescription
checkedboolean
null
The checked state of the useCheckbox.
indeterminateboolean
null
The indeterminate state of the useCheckbox.

Exposes#

Defines the methods and properties exposed by useCheckbox.

nametypedefaultdescription
stateuseCheckboxState
null
The state of the useCheckbox.
onChange(event: useCheckboxChangeEvent) => void
null
Callback fired when the useCheckbox's checked state changes.

Events#

Event fired when the checkbox's checked state changes.

nametypedescription
originalEventEThe original event that triggered the change.
checkedbooleanThe checked state of the checkbox.

Types#

Instance of useCheckbox headless.

values
HeadlessInstance<useCheckboxProps, useCheckboxState, useCheckboxExposes>