Checkbox
A custom-styled accessible checkbox with label, description text, error state, and three sizes. Forwards refs and spreads all native input attributes.
Import
tsx
import { Checkbox } from 'https://git.cameronlow.com/cam/VelocityUI/packages'Preview
Receive updates about your account activity.
Props
| Prop | Type | Default | Description |
|---|---|---|---|
| label | string | — | Label text rendered beside the checkbox. |
| description | string | — | Helper text rendered below the label. |
| error | string | — | Error message rendered below. Sets aria-invalid. |
| size | 'sm' | 'md' | 'lg' | 'md' | Controls the checkbox and label size. |
| checked | boolean | — | Controlled checked state. |
| defaultChecked | boolean | — | Uncontrolled default checked state. |
| disabled | boolean | false | Disables the checkbox. |
Examples
Basic
tsx
import { Checkbox } from 'https://git.cameronlow.com/cam/VelocityUI/packages'
export default function Example() {
return <Checkbox label="Accept terms and conditions" />
}With description
tsx
import { Checkbox } from 'https://git.cameronlow.com/cam/VelocityUI/packages'
export default function Example() {
return (
<Checkbox
label="Email notifications"
description="Receive updates about your account activity."
defaultChecked
/>
)
}Sizes
tsx
import { Checkbox } from 'https://git.cameronlow.com/cam/VelocityUI/packages'
export default function Example() {
return (
<div style={{ display: 'flex', flexDirection: 'column', gap: '0.75rem' }}>
<Checkbox size="sm" label="Small" defaultChecked />
<Checkbox size="md" label="Medium" defaultChecked />
<Checkbox size="lg" label="Large" defaultChecked />
</div>
)
}Theming
Apply a named theme class to <body> or any parent element. All VelocityUI components inside that element will automatically adopt its colors, shadows, and effects. Combine with a density modifier for complete control:
css
/* Pick any named theme */
<body class="vui-theme-ocean">
/* Add a density modifier (optional) */
<body class="vui-theme-midnight vui-density-compact">
<body class="vui-theme-construction vui-density-spacious">
/* Available themes */
/* default midnight ocean */
/* construction glass soft high-contrast monochrome-red */
/* Available densities */
/* vui-density-compact vui-density-comfortable vui-density-spacious */