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
Note Field
A notes box with a switch to show it formatted.
import { useState } from "react"
import { NoteField } from "@/registry/vcare/ui/note-field"
export default function NoteFieldDemo() {
const [v, setV] = useState("Complaints:\n- Fever for 3 days\n- Body ache\n\nAdvice:\nPlenty of fluids, **review in 3 days**.")
return (
<div className="w-full max-w-md">
<NoteField value={v} onChange={setV} />
</div>
)
}Installation
npx shadcn@latest add @vcare/note-fieldOr install directly from the URL: https://ui.vcarehms.com/r/note-field.json
- Install the dependencies:
npm i lucide-react - Add the registry items it uses: i18n, note-text, page-tabs, textarea.
- Copy this file into your project and change the
@/registry/vcare/…imports to your own paths.
components/ui/note-field.tsx
import { useState, type ReactNode } from 'react';
import { useTranslation } from '@/registry/vcare/lib/i18n';
import { Eye, Pencil } from 'lucide-react';
import { SegmentedTabs } from '@/registry/vcare/ui/page-tabs';
import { NoteText } from '@/registry/vcare/ui/note-text';
import { Textarea } from '@/registry/vcare/ui/textarea';
/**
* A text box for clinical writing with a Text | Formatted switch: Text is the box you type in, Formatted shows the same words as
* headings and bullets (the stored text is not changed). Use it wherever staff write notes, so every note box behaves alike.
* `leading` sits on the left of the switch (a label, or the kind of note).
*/
export function NoteField({
value,
onChange,
leading,
actions,
rows = 3,
placeholder,
id,
disabled,
maxLength,
'aria-label': ariaLabel,
}: {
value: string;
onChange: (v: string) => void;
leading?: ReactNode;
/** Extra buttons beside the switch (for example an AI draft button). */
actions?: ReactNode;
rows?: number;
placeholder?: string;
id?: string;
disabled?: boolean;
maxLength?: number;
'aria-label'?: string;
}) {
const { t } = useTranslation('common');
const label = (key: string, text: string) => t(key as never, { defaultValue: text } as never) as unknown as string;
const [formatted, setFormatted] = useState(false);
const showing = formatted && !!value.trim();
return (
<div className="space-y-2">
<div className="flex flex-wrap items-center justify-between gap-2">
<div className="min-w-0">{leading}</div>
<div className="flex flex-wrap items-center gap-2">
{actions}
<SegmentedTabs
value={showing ? 'view' : 'write'}
onChange={(v) => setFormatted(v === 'view')}
items={[
{ value: 'write', label: label('noteField.text', 'Text'), icon: <Pencil className="size-3.5" /> },
{ value: 'view', label: label('noteField.formatted', 'Formatted'), icon: <Eye className="size-3.5" />, disabled: !value.trim() },
]}
/>
</div>
</div>
{showing ? (
<div className="min-h-16 rounded-md border bg-muted/20 p-3" id={id}>
<NoteText text={value} />
</div>
) : (
<Textarea
id={id}
rows={Math.min(14, Math.max(rows, value.split('\n').length + 1))}
value={value}
disabled={disabled}
maxLength={maxLength}
aria-label={ariaLabel}
placeholder={placeholder}
onChange={(e) => onChange(e.target.value)}
/>
)}
</div>
);
}Usage
import { NoteField } from "@/components/ui/note-field"Exports
NoteField
Dependencies
lucide-react@^1.80.0(npm)@vcare/i18n(registry)@vcare/note-text(registry)@vcare/page-tabs(registry)@vcare/textarea(registry)
Raw item: /r/note-field.json