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
Sub Nav Layout
A page with its own section list on the left, like Settings.
import { useState } from "react"
import { Building2, FlaskConical, Pill, Users } from "lucide-react"
import { SubNavLayout } from "@/registry/vcare/ui/sub-nav-layout"
const items = [
{ id: "hospital", label: "Hospital", icon: Building2 },
{ id: "staff", label: "Staff and roles", icon: Users },
{ id: "lab", label: "Laboratory", icon: FlaskConical },
{ id: "pharmacy", label: "Pharmacy", icon: Pill },
]
export default function SubNavLayoutDemo() {
const [active, setActive] = useState("hospital")
return (
<div className="flex h-72 w-full overflow-hidden rounded-xl border bg-background">
<SubNavLayout items={items} base="#settings" active={active} onSelect={setActive}>
<h3 className="text-lg font-semibold">{items.find((i) => i.id === active)?.label}</h3>
<p className="text-sm text-muted-foreground">Settings for this section.</p>
</SubNavLayout>
</div>
)
}Installation
npx shadcn@latest add @vcare/sub-nav-layoutOr install directly from the URL: https://ui.vcarehms.com/r/sub-nav-layout.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/sub-nav-layout.tsx
import type { ReactNode } from 'react';
import type { LucideIcon } from 'lucide-react';
import { cn } from '@/registry/vcare/lib/utils';
export interface SubNavItem {
id: string;
label: string;
icon: LucideIcon;
hint?: string;
}
/** A page with its own left list of sections (like Settings): the list on the left, the chosen section on the right. Phones get pills on top. */
export function SubNavLayout({
items,
base,
active,
wide,
onSelect,
children,
}: {
items: SubNavItem[];
base: string;
active: string;
/** Let the section use the full width (tables). */
wide?: boolean;
/** Handle clicks yourself (client routing); links still carry an href. */
onSelect?: (id: string) => void;
children: ReactNode;
}) {
return (
<div className="flex min-h-0 min-w-0 flex-1">
<nav className="scrollbar-thin hidden w-60 shrink-0 space-y-0.5 overflow-y-auto border-e border-sidebar-border bg-sidebar p-1.5 sm:block">
{items.map(({ id, label, icon: Icon }) => (
<a
key={id}
href={`${base}/${id}`}
onClick={onSelect ? (e) => (e.preventDefault(), onSelect(id)) : undefined}
aria-current={id === active ? 'page' : undefined}
className={cn(
'flex h-nav items-center gap-3 rounded-xl px-3 text-[13px] font-medium leading-none text-sidebar-foreground transition-[background-color,color,box-shadow] duration-150 ease-power3-out hover:text-foreground',
id === active && 'nav-active!',
)}
>
<Icon className="size-4 shrink-0" />
<span className="truncate">{label}</span>
</a>
))}
</nav>
<div className="scrollbar-thin min-w-0 flex-1 overflow-y-auto">
<div className="flex gap-1 overflow-x-auto border-b p-2 sm:hidden">
{items.map(({ id, label, icon: Icon }) => (
<a
key={id}
href={`${base}/${id}`}
onClick={onSelect ? (e) => (e.preventDefault(), onSelect(id)) : undefined}
className={cn(
'inline-flex shrink-0 items-center gap-1.5 rounded-full px-3 py-1 text-xs',
id === active ? 'nav-active! font-medium' : 'text-sidebar-foreground',
)}
>
<Icon className="size-3.5" aria-hidden="true" />
{label}
</a>
))}
</div>
<div className={cn('space-y-4 p-4', !wide && 'max-w-4xl')}>{children}</div>
</div>
</div>
);
}Usage
import { SubNavLayout } from "@/components/ui/sub-nav-layout"Exports
SubNavLayout
Dependencies
lucide-react@^1.80.0(npm)@vcare/utils(registry)
Raw item: /r/sub-nav-layout.json