Documentation menu
Getting Started
Components
Primitives
- Agent Thinking
- Alert
- Alert Dialog
- Avatar
- Badge
- Breadcrumb
- Button
- Button Group
- Calendar
- Card
- Checkbox
- Command
- Command Palette
- Context Menu
- Data Table
- Dialog
- Dropdown Menu
- Empty
- Field
- Glow Cloud
- Input
- Label
- Medication Schedule
- Period Tabs
- Popover
- Rainbow Button
- Scroll Area
- Select
- Selectable Card
- Separator
- Sheet
- Sidebar
- Skeleton
- Slider
- Sonner
- Spinner
- Switch
- Table
- Tabs
- Tag
- Textarea
- Timeline
- Tooltip
- Use Count Up
Charts and metrics
Patterns
- Confirm Button
- Date Picker
- Embedded
- Empty State
- Entity Drawer
- Error Boundary
- Field Row
- File Dropzone
- Form Dialog
- Kv
- List Editor
- List Page
- Live Time
- Mini Table
- Money
- Note Field
- Note Text
- Page Card
- Page Header
- Page Tabs
- Page Toolbar
- Person Cell
- Picture Field
- Print Card
- Range Switcher
- Row Actions
- Search Input
- Search Select
- Selected Box
- Signature Pad
- Status Badge
- Sub Nav Layout
- Suggest Input
- Tab Icons
- Table Footer
- Theme Accent Picker
- Time Picker
- View All Link
Dashboard cards
Advanced
Device frames
Website widgets
Website screens
Website panels
Primitives
Selectable Card
A whole row that toggles a checkbox or switch, with a sentence of context.
import { Bell, Truck } from "lucide-react"
import { CheckboxCard, SwitchCard } from "@/registry/vcare/ui/selectable-card"
export default function SelectableCardDemo() {
return (
<div className="mx-auto grid w-full max-w-md gap-3">
<CheckboxCard title="Home collection" description="A technician visits the patient for samples." icon={<Truck className="size-4" />} />
<SwitchCard title="Report reminders" description="Message the patient when reports are released." icon={<Bell className="size-4" />} />
</div>
)
}Installation
npx shadcn@latest add @vcare/selectable-cardOr install directly from the URL: https://ui.vcarehms.com/r/selectable-card.json
- Add the registry items it uses: checkbox, switch, utils.
- Copy this file into your project and change the
@/registry/vcare/…imports to your own paths.
components/ui/selectable-card.tsx
import * as React from 'react';
import { cn } from '@/registry/vcare/lib/utils';
import { Checkbox } from '@/registry/vcare/ui/checkbox';
import { Switch } from '@/registry/vcare/ui/switch';
interface CardProps {
title: React.ReactNode;
description?: React.ReactNode;
icon?: React.ReactNode;
className?: string;
}
const base =
'flex w-full cursor-pointer items-center gap-3 rounded-2xl border border-input bg-card p-3 text-start transition-[border-color,background-color,box-shadow] duration-150 ease-power3-out has-[:focus-visible]:ring-2 has-[:focus-visible]:ring-ring/50 has-[[data-disabled]]:cursor-not-allowed has-[[data-disabled]]:opacity-50';
function Body({ title, description, icon }: Pick<CardProps, 'title' | 'description' | 'icon'>) {
return (
<>
{icon && <span className="grid size-9 shrink-0 place-items-center rounded-lg bg-muted text-muted-foreground [&>svg]:size-4">{icon}</span>}
<span className="min-w-0 flex-1 leading-tight">
<span className="block truncate text-sm font-medium">{title}</span>
{description && <span className="mt-0.5 block text-xs text-muted-foreground">{description}</span>}
</span>
</>
);
}
/** A whole row that toggles a checkbox: for choosing several options with a sentence of context each. */
export function CheckboxCard({
title,
description,
icon,
className,
...props
}: CardProps & Omit<React.ComponentProps<typeof Checkbox>, 'title' | 'className'>) {
return (
<label
data-slot="checkbox-card"
className={cn(base, 'has-[[data-state=checked]]:border-primary has-[[data-state=checked]]:bg-primary/5', className)}
>
<Body title={title} description={description} icon={icon} />
<Checkbox {...props} />
</label>
);
}
/** The same row with a switch: for settings that apply immediately. */
export function SwitchCard({
title,
description,
icon,
className,
...props
}: CardProps & Omit<React.ComponentProps<typeof Switch>, 'title' | 'className'>) {
return (
<label data-slot="switch-card" className={cn(base, className)}>
<Body title={title} description={description} icon={icon} />
<Switch {...props} />
</label>
);
}Usage
import { CheckboxCard, SwitchCard } from "@/components/ui/selectable-card"Exports
CheckboxCard, SwitchCard
Dependencies
@vcare/checkbox(registry)@vcare/switch(registry)@vcare/utils(registry)
Raw item: /r/selectable-card.json