Checkbox
Examples
Showcase
Dark Modern
import {ReactNode} from "react"import {Checkbox} from "@qui/react-vscode"export default function Showcase(): ReactNode {return (<div className="grid justify-center"><form className="grid grid-cols-4 grid-rows-3 items-center gap-x-8 gap-y-4"><div /><div className="text-foreground">Checked</div><div className="text-foreground">Unchecked</div><div className="text-foreground">Indeterminate</div><span className="text-foreground">Default</span><Checkbox defaultChecked label="Label" /><Checkbox label="Label" /><Checkbox indeterminate label="Label" /><span className="text-foreground">Disabled</span><Checkbox defaultChecked disabled label="Label" /><Checkbox disabled label="Label" /><Checkbox disabled indeterminate label="Label" /></form></div>)}
API
CheckboxProps
| Name & Description | Option(s) | Default |
|---|---|---|
The component used for the root node. It can be a React component or
element. |
| 'div' |
If true, React will focus the component on mount. |
| |
Controlled value for the component. |
| |
Default state. |
| |
If true, the component will not be interactive and will appear dimmed. |
| false |
Specifies the id of the <form> this input belongs to. If omitted, it’s the
closest parent form. |
| |
Controlled id. If omitted, a unique identifier will be automatically generated
for accessibility. |
| |
If true and the checkbox is not checked, the checkbox will be in the
indeterminate state. |
| |
attributes
applied to the input element. Use with caution. |
| {} |
Pass a ref to the input element. |
| |
Indicates the entered value does not conform to the format expected by the
application. |
| |
Optional label describing the element. Recommended. This element is
automatically associated with the component's input element for optimal
accessibility. | ReactNode | |
Specifies the name for this input that’s submitted with the form. |
| |
An Event handler function. Fires when the input element loses focus. |
| |
An Event handler function. Required for controlled inputs. Fires
immediately when the input’s value is changed by the user (for example).
Behaves like the browser input event with an additional parameter for
easily accessing the value. |
| |
An Event handler function. Fires when the input element gains focus. |
| |
If true, the component is not editable by the user. |
| false |
A string representing the value of the checkbox. This is not displayed on
the client-side, but on the server this is the value given to the data
submitted with the checkbox's name. If omitted and label is provided as a
string, the label will be used as a fallback value. |
|
Type
| ElementType| ComponentType
Default
'div'
Description
The component used for the root node. It can be a React component or
element.
Type
boolean
Description
If
true, React will focus the component on mount.Type
boolean
Description
Controlled value for the component.
Type
boolean
Description
Default state.
Type
boolean
Default
false
Description
If true, the component will not be interactive and will appear dimmed.
Type
string
Description
Specifies the id of the
<form> this input belongs to. If omitted, it’s the
closest parent form.Type
string
Description
Controlled id. If omitted, a unique identifier will be automatically generated
for accessibility.
Type
boolean
Description
If true and the checkbox is not checked, the checkbox will be in the
indeterminate state.
Type
InputHTMLAttributes<HTMLInputElement>
Default
{}Description
attributes
applied to the
input element. Use with caution.Type
Ref<HTMLInputElement>
Description
Pass a ref to the input element.
Type
boolean
Description
Indicates the entered value does not conform to the format expected by the
application.
Type
ReactNode
Description
Optional label describing the element. Recommended. This element is
automatically associated with the component's input element for optimal
accessibility.
Type
string
Description
Specifies the name for this input that’s submitted with the form.
Type
FocusEventHandler<HTMLInputElement>
Description
An Event handler function. Fires when the input element loses focus.
Type
(event: ChangeEvent<HTMLInputElement>,checked: boolean,) => void
Description
An Event handler function. Required for controlled inputs. Fires
immediately when the input’s value is changed by the user (for example).
Behaves like the browser input event with an additional parameter for
easily accessing the value.
Type
FocusEventHandler<HTMLInputElement>
Description
An Event handler function. Fires when the input element gains focus.
Type
boolean
Default
false
Description
If true, the component is not editable by the user.
Type
string
Description
A string representing the value of the checkbox. This is not displayed on
the client-side, but on the server this is the value given to the data
submitted with the checkbox's name. If omitted and label is provided as a
string, the label will be used as a fallback value.