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
Patterns
Selected Box
Shows the selected items with a total and actions.
import { useState } from "react"
import { SelectedBox } from "@/registry/vcare/ui/selected-box"
export default function SelectedBoxDemo() {
const [tests, setTests] = useState([
{ key: "cbc", name: "Complete blood count", price: 350 },
{ key: "lipid", name: "Lipid profile", price: 600 },
])
return (
<div className="w-full max-w-sm">
<SelectedBox
title="Selected tests"
totalLabel="Total"
total={`₹${tests.reduce((s, t) => s + t.price, 0)}`}
empty="Pick tests from the list."
removeLabel="Remove"
items={tests.map((t) => ({ key: t.key, name: t.name, price: `₹${t.price}`, remove: () => setTests((x) => x.filter((y) => y.key !== t.key)) }))}
/>
</div>
)
}Installation
npx shadcn@latest add @vcare/selected-boxOr install directly from the URL: https://ui.vcarehms.com/r/selected-box.json
- Install the dependencies:
npm i lucide-react - Add the registry items it uses: button.
- Copy this file into your project and change the
@/registry/vcare/…imports to your own paths.
components/ui/selected-box.tsx
import type { ReactNode } from 'react';
import { X } from 'lucide-react';
import { Button } from '@/registry/vcare/ui/button';
/**
* What has been picked (tests, studies…), in its own highlighted box: count, each item with its price and a remove
* button, and a big total, so the counter can see at a glance what the patient is paying for.
*/
export function SelectedBox({
title,
items,
total,
totalLabel,
empty,
removeLabel,
note,
}: {
title: string;
items: { key: string; name: string; price: string; remove: () => void }[];
total: string;
totalLabel: string;
empty: string;
removeLabel: string;
note?: ReactNode;
}) {
return (
<section className="overflow-hidden rounded-2xl bg-card shadow-border ring-2 ring-primary/30" aria-live="polite">
<header className="flex items-center justify-between gap-2 bg-primary/10 px-4 py-2.5 dark:bg-primary/20">
<h3 className="font-semibold">{title}</h3>
<span className="grid min-w-7 place-items-center rounded-full bg-primary px-2 py-0.5 text-xs font-bold text-primary-foreground tabular-nums">{items.length}</span>
</header>
{items.length ? (
<ul className="max-h-72 divide-y overflow-auto">
{items.map((l) => (
<li key={l.key} className="flex items-center gap-2 px-4 py-2">
<span className="min-w-0 flex-1 truncate text-[15px] font-medium">{l.name}</span>
<span className="tabular-nums" dir="ltr">
{l.price}
</span>
<Button type="button" variant="ghost" size="icon-sm" aria-label={`${removeLabel}: ${l.name}`} onClick={l.remove}>
<X />
</Button>
</li>
))}
</ul>
) : (
<p className="px-4 py-5 text-center text-sm text-muted-foreground">{empty}</p>
)}
{note && <div className="px-4 pb-2 text-xs text-subtle">{note}</div>}
<footer className="flex items-baseline justify-between border-t px-4 py-3">
<span className="font-semibold">{totalLabel}</span>
<span className="text-2xl font-bold tabular-nums text-primary dark:text-foreground" dir="ltr">
{total}
</span>
</footer>
</section>
);
}Usage
import { SelectedBox } from "@/components/ui/selected-box"Exports
SelectedBox
Dependencies
lucide-react@^1.80.0(npm)@vcare/button(registry)
Raw item: /r/selected-box.json