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
Field Row
Label and control laid out for dialogs and forms.
import { FieldRow } from "@/registry/vcare/ui/field-row"
import { Input } from "@/registry/vcare/ui/input"
export default function FieldRowDemo() {
return (
<div className="grid w-full max-w-md gap-3">
<FieldRow label="Patient name" required>
<Input />
</FieldRow>
<FieldRow label="Mobile" hint="Family members can share it">
<Input inputMode="tel" />
</FieldRow>
<FieldRow label="Email" error="Enter a valid email">
<Input aria-invalid defaultValue="meera@" />
</FieldRow>
<FieldRow label="Address" stacked>
<Input />
</FieldRow>
</div>
)
}Installation
npx shadcn@latest add @vcare/field-rowOr install directly from the URL: https://ui.vcarehms.com/r/field-row.json
- Add the registry items it uses: field.
- Copy this file into your project and change the
@/registry/vcare/…imports to your own paths.
components/ui/field-row.tsx
import { Children, cloneElement, isValidElement, useId, type ReactElement, type ReactNode } from 'react';
import { Field, FieldContent, FieldDescription, FieldError, FieldLabel } from '@/registry/vcare/ui/field';
/** ReUI-style label + control composition used by dialogs and forms. */
export function FieldRow({
label,
children,
stacked,
vertical,
required,
hint,
error,
className,
id,
}: {
label: string;
children: ReactNode;
stacked?: boolean;
/** label above the control, but still wired to it (use in multi-column grids) */ vertical?: boolean;
required?: boolean;
hint?: string;
error?: string;
className?: string;
id?: string;
}) {
const generatedId = useId();
const controlId = id ?? generatedId;
const descriptionId = hint || error ? `${controlId}-description` : undefined;
const only = Children.count(children) === 1 ? Children.only(children) : children;
const control =
!stacked && isValidElement(only)
? cloneElement(
only as ReactElement<{
id?: string;
'aria-describedby'?: string;
'aria-invalid'?: boolean;
'aria-required'?: boolean;
}>,
{
id: (only.props as { id?: string }).id ?? controlId,
...(descriptionId ? { 'aria-describedby': descriptionId } : {}),
...(error ? { 'aria-invalid': true } : {}),
...(required ? { 'aria-required': true } : {}),
},
)
: children;
return (
<Field orientation={stacked || vertical ? 'vertical' : 'responsive'} data-invalid={error ? '' : undefined} className={className}>
<FieldLabel htmlFor={stacked ? undefined : controlId}>
{label}
{required && (
<span aria-hidden="true" className="text-destructive">
{' '}
*
</span>
)}
</FieldLabel>
<FieldContent>
{control}
{error ? <FieldError id={descriptionId}>{error}</FieldError> : hint ? <FieldDescription id={descriptionId}>{hint}</FieldDescription> : null}
</FieldContent>
</Field>
);
}Usage
import { FieldRow } from "@/components/ui/field-row"Exports
FieldRow
Dependencies
@vcare/field(registry)
Raw item: /r/field-row.json