Checkbox

Examples

Showcase

Dark Modern
Checked
Unchecked
Indeterminate
Default
Disabled
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 & DescriptionOption(s)Default
The component used for the root node. It can be a React component or element.
| ElementType
| ComponentType
'div'
If true, React will focus the component on mount.
boolean
Controlled value for the component.
boolean
Default state.
boolean
If true, the component will not be interactive and will appear dimmed.
boolean
false
Specifies the id of the <form> this input belongs to. If omitted, it’s the closest parent form.
string
Controlled id. If omitted, a unique identifier will be automatically generated for accessibility.
string
If true and the checkbox is not checked, the checkbox will be in the indeterminate state.
boolean
attributes applied to the input element. Use with caution.
InputHTMLAttributes<HTMLInputElement>
{}
Pass a ref to the input element.
Ref<HTMLInputElement>
Indicates the entered value does not conform to the format expected by the application.
boolean
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.
string
An Event handler function. Fires when the input element loses focus.
FocusEventHandler<HTMLInputElement>
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.
      (
      event: ChangeEvent<HTMLInputElement>,
      checked: boolean,
      ) => void
      An Event handler function. Fires when the input element gains focus.
      FocusEventHandler<HTMLInputElement>
      If true, the component is not editable by the user.
      boolean
      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.
      string
      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.
      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.