- Accordion
- Alert
- Alert Dialog
- Aspect Ratio
- Attachment
- Autocomplete
- Avatar
- Badge
- Breadcrumb
- Bubble
- Button
- Calendar
- Card
- Carousel
- Chart
- Checkbox
- Checkbox Group
- Collapsible
- Combobox
- Command
- Context Menu
- Date Picker
- Dialog
- Drawer
- Dropdown Menu
- Empty
- Field
- Fieldset
- Form
- Frame
- Group
- Input
- Input Group
- Kbd
- Label
- Menu
- Menubar
- Message
- Meter
- Number Field
- OTP Field
- Pagination
- Popover
- Preview Card
- Progress
- Questionnaire
- Radio Group
- Scroll Area
- Select
- Separator
- Sheet
- Sidebar
- Skeleton
- Slider
- Spinner
- Switch
- Table
- Tabs
- Textarea
- Toggle
- Toggle Group
- Toolbar
- Tooltip
- Artifact
- Audio Player
- Canvas
- Chain of Thought
- Checkpoint
- Code Block
- Commit
- Connection
- Context
- Controls
- Edge
- Environment Variables
- Mic Selector
- Model Selector
- Node
- Node Toolbar
- Open in Chat
- Panel
- Plan
- Prompt Input
- Queue
- Reasoning
- Sandbox
- Schema Display
- Shimmer
- Snippet
- Sources
- Speech Input
- Stack Trace
- Suggestion
- Tool
- Transcription
- Web Preview
Checkbox
A control allowing the user to toggle between checked and not checked.
import { Checkbox } from "@/components/ui/checkbox";
import { Label } from "@/components/ui/label";
export default function Particle() {
return (
<Label>
<Checkbox />
Accept terms and conditions
</Label>
);
}
Installation
pnpm dlx shadcn@latest add @frontal-labs/checkbox
Usage
import { Checkbox } from "@/components/ui/checkbox";<Checkbox />API Reference
Checkbox
Styled wrapper for Checkbox.Root from Base UI. Includes a built-in indicator with a checkmark icon. All props from Checkbox.Root are supported.
In light mode the box carries a bg-muted fill on top of its border, so an unchecked checkbox stays visible against a white surface instead of relying on the border alone. When checked it switches to bg-primary with text-primary-foreground.
Examples
For accessible labelling and validation, prefer using the Field component to wrap checkboxes. See the related example: Checkbox field.
Disabled
import { Checkbox } from "@/components/ui/checkbox";
import { Label } from "@/components/ui/label";
export default function Particle() {
return (
<Label>
<Checkbox defaultChecked disabled />
Accept terms and conditions
</Label>
);
}
With Description
By clicking this checkbox, you agree to the terms and conditions.
import { useId } from "react";
import { Checkbox } from "@/components/ui/checkbox";
import { Label } from "@/components/ui/label";
export default function Particle() {
const id = useId();
return (
<div className="flex items-start gap-2">
<Checkbox defaultChecked id={id} />
<div className="flex flex-col gap-1">
<Label htmlFor={id}>Accept terms and conditions</Label>
<p className="text-muted-foreground text-xs">
By clicking this checkbox, you agree to the terms and conditions.
</p>
</div>
</div>
);
}
Card Style
import { Checkbox } from "@/components/ui/checkbox";
import { Label } from "@/components/ui/label";
export default function Particle() {
return (
<Label className="flex items-start gap-2 rounded-md border p-3 hover:bg-accent/50 has-data-checked:border-primary/48 has-data-checked:bg-accent/50">
<Checkbox defaultChecked />
<div className="flex flex-col gap-1">
<p>Enable notifications</p>
<p className="text-muted-foreground text-xs">
You can enable or disable notifications at any time.
</p>
</div>
</Label>
);
}
Form Integration
Field provides accessible labelling and validation primitives for form controls. Use it with Form to submit values.
"use client";
import type { FormEvent } from "react";
import { useState } from "react";
import { Button } from "@/components/ui/button";
import { Checkbox } from "@/components/ui/checkbox";
import { Field, FieldLabel } from "@/components/ui/field";
import { Spinner } from "@/components/ui/spinner";
export default function Particle() {
const [loading, setLoading] = useState(false);
const onSubmit = async (e: FormEvent<HTMLFormElement>) => {
e.preventDefault();
const formData = new FormData(e.currentTarget);
setLoading(true);
await new Promise((r) => setTimeout(r, 800));
setLoading(false);
const accepted = formData.get("terms");
alert(`Terms: ${accepted}`);
};
return (
<form className="flex w-auto flex-col gap-4" onSubmit={onSubmit}>
<Field>
<FieldLabel>
<Checkbox defaultChecked value="yes" />
Accept terms and conditions
</FieldLabel>
</Field>
<Button disabled={loading} type="submit">
{loading && <Spinner />}
Submit
</Button>
</form>
);
}