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
Picture Field
Choose one picture from a set.
import { useState } from "react"
import { PictureField } from "@/registry/vcare/ui/picture-field"
const pictures = ["empty-appointments", "empty-bills", "empty-cart", "empty-documents", "empty-reports", "empty-visits"].map((n) => ({
name: `states/${n}`,
url: `/art/states/${n}.webp`,
}))
export default function PictureFieldDemo() {
const [v, setV] = useState<string | null>("states/empty-bills")
return (
<div className="w-full max-w-md">
<PictureField pictures={pictures} value={v} onChange={setV} />
</div>
)
}Installation
npx shadcn@latest add @vcare/picture-fieldOr install directly from the URL: https://ui.vcarehms.com/r/picture-field.json
- Install the dependencies:
npm i lucide-react - Add the registry items it uses: utils.
- Copy this file into your project and change the
@/registry/vcare/…imports to your own paths.
components/ui/picture-field.tsx
import { X } from 'lucide-react';
import { cn } from '@/registry/vcare/lib/utils';
export interface Picture {
name: string;
url: string;
}
/** Chooses one picture from a set. The value is the picture's name, such as `tiles/visit/heart`. */
export function PictureField({ pictures, value, onChange }: { pictures: Picture[]; value?: string | null; onChange: (v: string | null) => void }) {
return (
<div className="space-y-2">
<div className="grid grid-cols-[repeat(auto-fill,minmax(64px,1fr))] gap-2">
{pictures.map((p) => (
<button
key={p.name}
type="button"
title={p.name.split('/').pop()}
aria-pressed={value === p.name}
onClick={() => onChange(value === p.name ? null : p.name)}
className={cn(
'grid aspect-square place-items-center rounded-xl border bg-muted/50 p-1.5 transition-[box-shadow,border-color,background-color] hover:bg-muted',
value === p.name && 'border-primary bg-card ring-2 ring-primary/40',
)}
>
<img src={p.url} alt={p.name.split('/').pop() ?? ''} className="size-full object-contain" />
</button>
))}
</div>
{value && (
<button type="button" onClick={() => onChange(null)} className="inline-flex items-center gap-1 text-xs text-muted-foreground hover:text-foreground">
<X className="size-3" />
{value.split('/').pop()}
</button>
)}
</div>
);
}Usage
import { PictureField } from "@/components/ui/picture-field"Exports
PictureField
Dependencies
lucide-react@^1.80.0(npm)@vcare/utils(registry)
Raw item: /r/picture-field.json