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
Field
Label, description and error for a form control.
import { Field, FieldContent, FieldDescription, FieldError, FieldGroup, FieldLabel } from "@/registry/vcare/ui/field"
import { Input } from "@/registry/vcare/ui/input"
export default function FieldDemo() {
return (
<FieldGroup className="mx-auto w-full max-w-sm">
<Field>
<FieldLabel htmlFor="pname">Patient name</FieldLabel>
<Input id="pname" placeholder="As on ID" />
<FieldDescription>Used on bills and reports.</FieldDescription>
</Field>
<Field orientation="horizontal">
<FieldLabel htmlFor="age">Age</FieldLabel>
<FieldContent>
<Input id="age" type="number" aria-invalid defaultValue={-2} />
<FieldError>Age must be 0 or more.</FieldError>
</FieldContent>
</Field>
</FieldGroup>
)
}Installation
npx shadcn@latest add @vcare/fieldOr install directly from the URL: https://ui.vcarehms.com/r/field.json
- Add the registry items it uses: label, utils.
- Copy this file into your project and change the
@/registry/vcare/…imports to your own paths.
components/ui/field.tsx
import * as React from 'react';
import { cn } from '@/registry/vcare/lib/utils';
import { Label } from '@/registry/vcare/ui/label';
function Field({
className,
orientation = 'vertical',
...props
}: React.ComponentProps<'div'> & {
orientation?: 'vertical' | 'horizontal' | 'responsive';
}) {
return (
<div
data-slot="field"
data-orientation={orientation}
className={cn(
'group/field min-w-0',
orientation === 'vertical' && 'flex flex-col gap-1.5',
orientation === 'horizontal' && 'grid grid-cols-[8.5rem_minmax(0,1fr)] items-center gap-3',
orientation === 'responsive' && 'grid gap-1.5 sm:grid-cols-[8.5rem_minmax(0,1fr)] sm:items-center sm:gap-3',
className,
)}
{...props}
/>
);
}
function FieldContent({ className, ...props }: React.ComponentProps<'div'>) {
return <div data-slot="field-content" className={cn('min-w-0', className)} {...props} />;
}
function FieldLabel({ className, ...props }: React.ComponentProps<typeof Label>) {
return <Label data-slot="field-label" className={cn('text-sm font-normal text-muted-foreground', className)} {...props} />;
}
function FieldDescription({ className, ...props }: React.ComponentProps<'p'>) {
return <p data-slot="field-description" className={cn('mt-1 text-xs text-subtle', className)} {...props} />;
}
function FieldError({ className, ...props }: React.ComponentProps<'p'>) {
return <p data-slot="field-error" role="alert" className={cn('mt-1 text-xs text-destructive', className)} {...props} />;
}
function FieldGroup({ className, ...props }: React.ComponentProps<'div'>) {
return <div data-slot="field-group" className={cn('space-y-3.5', className)} {...props} />;
}
export { Field, FieldContent, FieldDescription, FieldError, FieldGroup, FieldLabel };Usage
import { Field, FieldContent, FieldDescription, FieldError, FieldGroup, FieldLabel } from "@/components/ui/field"Exports
Field, FieldContent, FieldDescription, FieldError, FieldGroup, FieldLabel
Dependencies
@vcare/label(registry)@vcare/utils(registry)
Raw item: /r/field.json