Components
- Accordion
- Alert
- Alert Dialog
- Aspect Ratio
- Autocomplete
- Avatar
- Badge
- Bar List
- Breadcrumb
- Button
- Button Group
- Calendar
- Card
- Carousel
- Checkbox
- Checkbox Group
- Circular Progress
- Collapsible
- Combobox
- Command
- Context Menu
- Currency Input
- Data Table
- Date Picker
- Dialog
- Drawer
- Dropdown Menu
- Empty
- Field
- Hover Card
- Input
- Input Group
- Input OTP
- Item
- Kbd
- Label
- Menubar
- Meter
- Multi Combobox
- Native Select
- Navigation Menu
- Number Field
- Pagination
- Phone Input
- Popover
- Progress
- Progress List
- Prompt
- Radio Group
- Resizable
- Scroll Area
- Select
- Separator
- Sheet
- Sidebar
- Skeleton
- Slider
- Sonner
- Spinner
- Stat
- Switch
- Table
- Tabs
- Textarea
- Toggle
- Toggle Group
- Tooltip
- Typography
Loading...
"use client";
import { useId } from "react";
import { Checkbox } from "@/components/ui/checkbox";
import {
CheckboxGroup,
CheckboxGroupLabel,
} from "@/components/ui/checkbox-group";
export function CheckboxGroupDemo() {
const id = useId();
const fujiId = `${id}-fuji`;
const galaId = `${id}-gala`;
const grannySmithId = `${id}-granny-smith`;
return (
<CheckboxGroup
aria-labelledby={id}
className="w-full max-w-xs"
defaultValue={["fuji-apple"]}
>
<CheckboxGroupLabel id={id}>Apples</CheckboxGroupLabel>
<div className="flex items-center gap-2 font-normal text-sm">
<Checkbox id={fujiId} name="apple" value="fuji-apple" />
<label htmlFor={fujiId}>Fuji</label>
</div>
<div className="flex items-center gap-2 font-normal text-sm">
<Checkbox id={galaId} name="apple" value="gala-apple" />
<label htmlFor={galaId}>Gala</label>
</div>
<div className="flex items-center gap-2 font-normal text-sm">
<Checkbox id={grannySmithId} name="apple" value="granny-smith-apple" />
<label htmlFor={grannySmithId}>Granny Smith</label>
</div>
</CheckboxGroup>
);
}Installation
npx shadcn@latest add "https://ui.blode.co/r/styles/default/checkbox-group"
Usage
import { Checkbox } from "@/components/ui/checkbox";
import {
CheckboxGroup,
CheckboxGroupLabel,
} from "@/components/ui/checkbox-group";const fujiId = "apple-fuji";
const galaId = "apple-gala";
<CheckboxGroup defaultValue={["fuji-apple"]}>
<CheckboxGroupLabel>Apples</CheckboxGroupLabel>
<div className="flex items-center gap-2">
<Checkbox id={fujiId} name="apple" value="fuji-apple" />
<label htmlFor={fujiId}>Fuji</label>
</div>
<div className="flex items-center gap-2">
<Checkbox id={galaId} name="apple" value="gala-apple" />
<label htmlFor={galaId}>Gala</label>
</div>
</CheckboxGroup>