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
List Editor
An editable list of rows (allergies, conditions, medications…) with add and remove.
import { useState } from "react"
import { Input } from "@/registry/vcare/ui/input"
import { ListEditor } from "@/registry/vcare/ui/list-editor"
type Allergy = { name: string; reaction: string }
export default function ListEditorDemo() {
const [items, setItems] = useState<Allergy[]>([{ name: "Penicillin", reaction: "Rash" }])
return (
<div className="w-full max-w-md">
<ListEditor
items={items}
onChange={setItems}
blank={() => ({ name: "", reaction: "" })}
addLabel="Add allergy"
render={(item, set) => (
<div className="grid flex-1 grid-cols-2 gap-2">
<Input value={item.name} placeholder="Allergy" onChange={(e) => set({ name: e.target.value })} />
<Input value={item.reaction} placeholder="Reaction" onChange={(e) => set({ reaction: e.target.value })} />
</div>
)}
/>
</div>
)
}Installation
npx shadcn@latest add @vcare/list-editorOr install directly from the URL: https://ui.vcarehms.com/r/list-editor.json
- Install the dependencies:
npm i lucide-react - Add the registry items it uses: button, i18n.
- Copy this file into your project and change the
@/registry/vcare/…imports to your own paths.
components/ui/list-editor.tsx
import type { ReactNode } from 'react';
import { useTranslation } from '@/registry/vcare/lib/i18n';
import { Plus, X } from 'lucide-react';
import { Button } from '@/registry/vcare/ui/button';
/** Editable list of rows (allergies, conditions, medications…). `render` draws the inputs for one row. */
export function ListEditor<T>({
items,
onChange,
render,
blank,
addLabel,
}: {
items: T[];
onChange: (items: T[]) => void;
render: (item: T, set: (patch: Partial<T>) => void) => ReactNode;
blank: () => T;
addLabel?: string;
}) {
const { t } = useTranslation();
return (
<div className="space-y-2">
{items.map((item, i) => (
<div key={i} className="flex items-start gap-2">
<div className="grid min-w-0 flex-1 grid-cols-2 gap-2">
{render(item, (patch) => onChange(items.map((x, j) => (j === i ? { ...x, ...patch } : x))))}
</div>
<Button type="button" variant="ghost" size="icon-sm" aria-label={t('remove')} onClick={() => onChange(items.filter((_, j) => j !== i))}>
<X />
</Button>
</div>
))}
<Button type="button" variant="secondary" size="sm" onClick={() => onChange([...items, blank()])}>
<Plus />
{addLabel ?? t('add')}
</Button>
</div>
);
}Usage
import { ListEditor } from "@/components/ui/list-editor"Exports
ListEditor
Dependencies
lucide-react@^1.80.0(npm)@vcare/button(registry)@vcare/i18n(registry)
Raw item: /r/list-editor.json