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
Form Dialog
A form in a side sheet, with cancel and save.
import { useState } from "react"
import { Button } from "@/registry/vcare/ui/button"
import { FieldRow } from "@/registry/vcare/ui/field-row"
import { FormDialog } from "@/registry/vcare/ui/form-dialog"
import { Input } from "@/registry/vcare/ui/input"
export default function FormDialogDemo() {
const [open, setOpen] = useState(false)
return (
<>
<Button onClick={() => setOpen(true)}>New supplier</Button>
<FormDialog open={open} onOpenChange={setOpen} title="New supplier" description="Used for purchase orders." onSubmit={() => setOpen(false)}>
<FieldRow label="Name" required>
<Input />
</FieldRow>
<FieldRow label="GSTIN" hint="15 characters">
<Input />
</FieldRow>
<FieldRow label="Phone">
<Input inputMode="tel" />
</FieldRow>
</FormDialog>
</>
)
}Installation
npx shadcn@latest add @vcare/form-dialogOr install directly from the URL: https://ui.vcarehms.com/r/form-dialog.json
- Install the dependencies:
npm i lucide-react - Add the registry items it uses: button, i18n, sheet.
- Copy this file into your project and change the
@/registry/vcare/…imports to your own paths.
components/ui/form-dialog.tsx
import type { ReactNode } from 'react';
import { useTranslation } from '@/registry/vcare/lib/i18n';
import { Button } from '@/registry/vcare/ui/button';
import { X } from 'lucide-react';
import { Sheet, SheetClose, SheetContent, SheetDescription, SheetHeader, SheetTitle } from '@/registry/vcare/ui/sheet';
/**
* Standard form surface: an end-side drawer with a header, scrollable body and a sticky Cancel/Save footer.
* (Named FormDialog for its many callers; `wide`/`xl` pick the drawer width.)
*/
export function FormDialog({
open,
onOpenChange,
title,
description,
children,
onSubmit,
submitLabel,
cancelLabel,
busy,
error,
disabled,
wide,
xl,
}: {
open: boolean;
onOpenChange: (o: boolean) => void;
title: string;
description?: string;
children: ReactNode;
onSubmit: () => void;
submitLabel?: string;
cancelLabel?: string;
busy?: boolean;
error?: string | null;
disabled?: boolean;
wide?: boolean;
xl?: boolean;
}) {
const { t, i18n } = useTranslation();
return (
<Sheet open={open} onOpenChange={onOpenChange}>
<SheetContent
side={i18n.dir() === 'rtl' ? 'left' : 'right'}
showCloseButton={false}
floating
className={`flex flex-col gap-0 overflow-hidden p-0 ${xl ? 'sm:max-w-[68rem]' : wide ? 'sm:max-w-[46rem]' : 'sm:max-w-[30rem]'}`}
>
<form
className="flex min-h-0 flex-1 flex-col"
onSubmit={(e) => {
e.preventDefault();
if (!busy && !disabled) onSubmit();
}}
>
<SheetHeader className="page-sky h-16 shrink-0 flex-row items-center justify-between gap-3 border-b px-6 py-0">
<div className="min-w-0">
<SheetTitle className="truncate text-lg font-extrabold tracking-tight">{title}</SheetTitle>
<SheetDescription className={description ? 'truncate text-xs' : 'sr-only'}>{description ?? title}</SheetDescription>
</div>
<SheetClose asChild>
<Button type="button" variant="ghost" size="icon-sm" aria-label={t('close')}>
<X />
</Button>
</SheetClose>
</SheetHeader>
<div className="min-h-0 flex-1 space-y-4 overflow-y-auto px-6 py-5 scrollbar-thin">{children}</div>
{error && (
<p role="alert" className="shrink-0 border-t px-5 pt-2 text-xs text-destructive">
{error}
</p>
)}
<div className="flex shrink-0 justify-end gap-2 border-t px-5 py-3.5">
<Button type="button" variant="secondary" onClick={() => onOpenChange(false)}>
{cancelLabel ?? t('cancel')}
</Button>
<Button type="submit" disabled={busy || disabled}>
{submitLabel ?? t('save')}
</Button>
</div>
</form>
</SheetContent>
</Sheet>
);
}Usage
import { FormDialog } from "@/components/ui/form-dialog"Exports
FormDialog
Dependencies
lucide-react@^1.80.0(npm)@vcare/button(registry)@vcare/i18n(registry)@vcare/sheet(registry)
Raw item: /r/form-dialog.json