# Building Blocks for the Web

Clean, modern building blocks. Copy and paste into your apps. Works with any WebJs app. Open Source. Free forever.

Source: https://webjs.dev/ui/blocks

[View Components](https://webjs.dev/ui/docs/components)

[Browse all blocks](https://webjs.dev/ui/blocks/sidebar)

## Dashboard 01

A dashboard with sidebar, charts and data table.

Install it with the CLI, which copies these files into your app:

```bash
npx @webjsdev/ui add dashboard-01
```

Preview: https://webjs.dev/ui/view/dashboard-01

```ts title="app/dashboard/page.ts"
/**
 * The dashboard-01 block's page: an inset sidebar beside a header, four
 * metric cards, an interactive area chart and a data table.
 *
 * Installed by `npx @webjsdev/ui add dashboard-01` at `app/dashboard/page.ts`.
 * It is app code you own, so edit it freely: replace `dashboardData` with
 * rows from your own query. Ported from shadcn/ui's dashboard-01.
 */
import { html } from '@webjsdev/core';
import type { Metadata } from '@webjsdev/core';
import '../../components/ui/sidebar.ts';
import { appSidebar } from '../../components/app-sidebar.ts';
import { chartAreaInteractive } from '../../components/chart-area-interactive.ts';
import { dashboardData } from '../../components/dashboard-data.ts';
import { dataTable } from '../../components/data-table.ts';
import { sectionCards } from '../../components/section-cards.ts';
import { siteHeader } from '../../components/site-header.ts';

export const metadata: Metadata = { title: 'Dashboard' };

export default function DashboardPage() {
  return html`
    <ui-sidebar-provider class="[--header-height:calc(var(--spacing)*12)]">
      ${appSidebar({ variant: 'inset' })}
      <ui-sidebar-inset>
        ${siteHeader()}
        <div class="flex flex-1 flex-col">
          <div class="@container/main flex flex-1 flex-col gap-2">
            <div class="flex flex-col gap-4 py-4 md:gap-6 md:py-6">
              ${sectionCards()}
              <div class="px-4 lg:px-6">${chartAreaInteractive()}</div>
              ${dataTable({ data: dashboardData })}
            </div>
          </div>
        </div>
      </ui-sidebar-inset>
    </ui-sidebar-provider>
  `;
}
```

```ts title="components/app-sidebar.ts"
/**
 * The dashboard-01 app sidebar: the brand, the main nav with "Quick Create",
 * the documents list, the secondary links pinned to the bottom, and the
 * signed-in user, in an inset sidebar that slides off canvas (Ctrl+B or
 * Cmd+B, or the header's trigger). A fragment helper, so the markup is
 * rendered by the server; the sidebar and the menus are the kit's elements.
 * Ported from shadcn/ui's dashboard-01.
 *
 * The data below is sample data. Replace it with your own, and point each
 * `url` at a real route. The options shape the shell for other layouts:
 * `collapsible` (`'offcanvas'` by default, `'none'` for a fixed column),
 * `class` and `headerClass` added to the sidebar and its header, `logo` in
 * place of the brand icon, `mainLabel` / `quickCreate` passed to the main
 * nav, and `data` to replace any of the sample lists.
 */
import { html } from '@webjsdev/core';
import type { TemplateResult } from '@webjsdev/core';
import { cn } from '../lib/utils/cn.ts';
import {
  sidebarContentClass,
  sidebarFooterClass,
  sidebarHeaderClass,
  sidebarMenuButtonClass,
  sidebarMenuClass,
  sidebarMenuItemClass,
} from './ui/sidebar.ts';
import { navDocuments, type NavDocument } from './nav-documents.ts';
import { navMain, type NavMainItem } from './nav-main.ts';
import { navSecondary, type NavSecondaryItem } from './nav-secondary.ts';
import { navUser } from './nav-user.ts';
import { ChartBarIcon, CircleHelpIcon, CommandIcon, DatabaseIcon, FileChartColumnIcon, FileIcon, FolderIcon, LayoutDashboardIcon, ListIcon, SearchIcon, Settings2Icon, UsersIcon } from '../lib/utils/icons.ts';

export interface AppSidebarData {
  user: { name: string; email: string; avatar: string };
  navMain: NavMainItem[];
  navSecondary: NavSecondaryItem[];
  documents: NavDocument[];
}

export interface AppSidebarOptions {
  variant?: 'sidebar' | 'floating' | 'inset';
  collapsible?: 'offcanvas' | 'icon' | 'none';
  class?: string;
  headerClass?: string;
  logo?: TemplateResult;
  mainLabel?: string;
  quickCreate?: boolean;
  data?: Partial<AppSidebarData>;
}

// This is sample data.
const data: AppSidebarData = {
  user: {
    name: 'vivek',
    email: 'vivek@example.com',
    avatar: 'https://webjs.dev/avatars/vivek.jpg',
  },
  navMain: [
    { title: 'Dashboard', url: '#', icon: LayoutDashboardIcon },
    { title: 'Lifecycle', url: '#', icon: ListIcon },
    { title: 'Analytics', url: '#', icon: ChartBarIcon },
    { title: 'Projects', url: '#', icon: FolderIcon },
    { title: 'Team', url: '#', icon: UsersIcon },
  ],
  navSecondary: [
    { title: 'Settings', url: '#', icon: Settings2Icon },
    { title: 'Get Help', url: '#', icon: CircleHelpIcon },
    { title: 'Search', url: '#', icon: SearchIcon },
  ],
  documents: [
    { name: 'Data Library', url: '#', icon: DatabaseIcon },
    { name: 'Reports', url: '#', icon: FileChartColumnIcon },
    { name: 'Word Assistant', url: '#', icon: FileIcon },
  ],
};

/**
 * The sidebar. shadcn's page widens it to 18rem through the provider's
 * `--sidebar-width`; the kit's provider sets its own on the wrapper it
 * renders, so the width rides on the sidebar itself here. A `class` that sets
 * its own `--sidebar-width` replaces this one, as shadcn's merge would.
 */
export function appSidebar(opts: AppSidebarOptions = {}) {
  const d = { ...data, ...opts.data };
  const width = opts.class?.includes('[--sidebar-width:') ? '' : '[--sidebar-width:calc(var(--spacing)*72)]';
  return html`
    <ui-sidebar collapsible=${opts.collapsible ?? 'offcanvas'} variant=${opts.variant ?? 'sidebar'} class=${cn(width, opts.class)}>
      <div data-slot="sidebar-header" data-sidebar="header" class=${cn(sidebarHeaderClass(), opts.headerClass)}>
        <ul data-slot="sidebar-menu" data-sidebar="menu" class=${sidebarMenuClass()}>
          <li data-slot="sidebar-menu-item" data-sidebar="menu-item" class=${sidebarMenuItemClass()}>
            <a href="#" data-slot="sidebar-menu-button" data-sidebar="menu-button" data-size="default" class=${cn(sidebarMenuButtonClass(), 'data-[slot=sidebar-menu-button]:p-1.5!')}>
              ${opts.logo ?? CommandIcon('size-5!')}
              <span class="text-base font-semibold">Acme Inc.</span>
            </a>
          </li>
        </ul>
      </div>
      <div data-slot="sidebar-content" data-sidebar="content" class=${sidebarContentClass()}>
        ${navMain({ items: d.navMain, label: opts.mainLabel, quickCreate: opts.quickCreate })}
        ${navDocuments({ items: d.documents })}
        ${navSecondary({ items: d.navSecondary, class: 'mt-auto' })}
      </div>
      <div data-slot="sidebar-footer" data-sidebar="footer" class=${sidebarFooterClass()}>
        ${navUser({ user: d.user })}
      </div>
    </ui-sidebar>
  `;
}
```

```ts title="components/nav-main.ts"
/**
 * The dashboard-01 main nav: the "Quick Create" button beside an inbox
 * button, then one link per section. A fragment helper. Ported from
 * shadcn/ui's dashboard-01.
 *
 * "Quick Create" and the inbox button are placeholders: point them at your
 * own create flow and inbox route. `quickCreate: false` drops that row and
 * `label` titles the group (shadcn's examples/dashboard has a "Home" group with
 * no Quick Create row).
 */
import { html } from '@webjsdev/core';
import type { TemplateResult } from '@webjsdev/core';
import { cn } from '../lib/utils/cn.ts';
import { buttonClass } from './ui/button.ts';
import {
  sidebarGroupClass,
  sidebarGroupContentClass,
  sidebarGroupLabelClass,
  sidebarMenuButtonClass,
  sidebarMenuClass,
  sidebarMenuItemClass,
} from './ui/sidebar.ts';
import { CirclePlusIcon, MailIcon } from '../lib/utils/icons.ts';

export interface NavMainItem {
  title: string;
  url: string;
  icon?: (cls?: string) => TemplateResult;
}

export function navMain({ items, label, quickCreate = true }: { items: NavMainItem[]; label?: string; quickCreate?: boolean }) {
  return html`
    <div data-slot="sidebar-group" data-sidebar="group" class=${sidebarGroupClass()}>
      <div data-slot="sidebar-group-content" data-sidebar="group-content" class=${cn(sidebarGroupContentClass(), 'flex flex-col gap-2')}>
        ${label ? html`<div data-slot="sidebar-group-label" data-sidebar="group-label" class=${sidebarGroupLabelClass()}>${label}</div>` : ''}
        ${quickCreate ? html`<ul data-slot="sidebar-menu" data-sidebar="menu" class=${sidebarMenuClass()}>
          <li data-slot="sidebar-menu-item" data-sidebar="menu-item" class=${cn(sidebarMenuItemClass(), 'flex items-center gap-2')}>
            <button type="button" data-slot="sidebar-menu-button" data-sidebar="menu-button" data-size="default" class=${cn(sidebarMenuButtonClass(), 'min-w-8 bg-primary text-primary-foreground duration-200 ease-linear hover:bg-primary/90 hover:text-primary-foreground active:bg-primary/90 active:text-primary-foreground')}>
              ${CirclePlusIcon()}
              <span>Quick Create</span>
            </button>
            <button type="button" data-slot="button" data-variant="outline" data-size="icon" class=${cn(buttonClass({ variant: 'outline', size: 'icon' }), 'size-8 group-data-[collapsible=icon]:opacity-0')}>
              ${MailIcon()}
              <span class="sr-only">Inbox</span>
            </button>
          </li>
        </ul>` : ''}
        <ul data-slot="sidebar-menu" data-sidebar="menu" class=${sidebarMenuClass()}>
          ${items.map((item) => html`
            <li data-slot="sidebar-menu-item" data-sidebar="menu-item" class=${sidebarMenuItemClass()}>
              <a href=${item.url} data-slot="sidebar-menu-button" data-sidebar="menu-button" data-size="default" class=${sidebarMenuButtonClass()}>
                ${item.icon ? item.icon() : ''}
                <span>${item.title}</span>
              </a>
            </li>
          `)}
        </ul>
      </div>
    </div>
  `;
}
```

```ts title="components/nav-documents.ts"
/**
 * The dashboard-01 documents list: one link per document, each with a "More"
 * menu that shows on hover, and a trailing "More" item. Hidden while the
 * sidebar is collapsed to icons. A fragment helper; the menus are the kit's
 * `<ui-dropdown-menu>`. Ported from shadcn/ui's dashboard-01.
 *
 * Each "More" button sits right after its link, a sibling of it, because the
 * kit's styles place it with `peer-*` selectors that need exactly that. The
 * menu names it through `trigger="<id>"`, so the ids must be unique on the page.
 */
import { html } from '@webjsdev/core';
import type { TemplateResult } from '@webjsdev/core';
import { cn } from '../lib/utils/cn.ts';
import './ui/dropdown-menu.ts';
import {
  sidebarGroupClass,
  sidebarGroupLabelClass,
  sidebarMenuActionClass,
  sidebarMenuButtonClass,
  sidebarMenuClass,
  sidebarMenuItemClass,
} from './ui/sidebar.ts';
import { FolderIcon, MoreHorizontalIcon, ShareIcon, Trash2Icon } from '../lib/utils/icons.ts';

export interface NavDocument {
  name: string;
  url: string;
  icon: (cls?: string) => TemplateResult;
}

export function navDocuments({ items }: { items: NavDocument[] }) {
  return html`
    <div data-slot="sidebar-group" data-sidebar="group" class=${cn(sidebarGroupClass(), 'group-data-[collapsible=icon]:hidden')}>
      <div data-slot="sidebar-group-label" data-sidebar="group-label" class=${sidebarGroupLabelClass()}>Documents</div>
      <ul data-slot="sidebar-menu" data-sidebar="menu" class=${sidebarMenuClass()}>
        ${items.map((item, i) => html`
          <li data-slot="sidebar-menu-item" data-sidebar="menu-item" class=${sidebarMenuItemClass()}>
            <a href=${item.url} data-slot="sidebar-menu-button" data-sidebar="menu-button" data-size="default" class=${sidebarMenuButtonClass()}>
              ${item.icon()}
              <span>${item.name}</span>
            </a>
            <button type="button" id=${`nav-document-more-${i}`} data-slot="sidebar-menu-action" data-sidebar="menu-action" class=${cn(sidebarMenuActionClass({ showOnHover: true }), 'rounded-sm aria-expanded:bg-accent')}>
              ${MoreHorizontalIcon()}
              <span class="sr-only">More</span>
            </button>
            <ui-dropdown-menu trigger=${`nav-document-more-${i}`}>
              <ui-dropdown-menu-content class="w-24 rounded-lg" side="right" align="start">
                <ui-dropdown-menu-item>${FolderIcon()}<span>Open</span></ui-dropdown-menu-item>
                <ui-dropdown-menu-item>${ShareIcon()}<span>Share</span></ui-dropdown-menu-item>
                <ui-dropdown-menu-separator></ui-dropdown-menu-separator>
                <ui-dropdown-menu-item variant="destructive">${Trash2Icon()}<span>Delete</span></ui-dropdown-menu-item>
              </ui-dropdown-menu-content>
            </ui-dropdown-menu>
          </li>
        `)}
        <li data-slot="sidebar-menu-item" data-sidebar="menu-item" class=${sidebarMenuItemClass()}>
          <button type="button" data-slot="sidebar-menu-button" data-sidebar="menu-button" data-size="default" class=${cn(sidebarMenuButtonClass(), 'text-sidebar-foreground/70')}>
            ${MoreHorizontalIcon('text-sidebar-foreground/70')}
            <span>More</span>
          </button>
        </li>
      </ul>
    </div>
  `;
}
```

```ts title="components/nav-secondary.ts"
/**
 * The dashboard-01 secondary nav: settings, help and search, pinned to the
 * bottom of the sidebar by the `class` the app sidebar passes (`mt-auto`).
 * A fragment helper. Ported from shadcn/ui's dashboard-01.
 */
import { html } from '@webjsdev/core';
import type { TemplateResult } from '@webjsdev/core';
import { cn } from '../lib/utils/cn.ts';
import {
  sidebarGroupClass,
  sidebarGroupContentClass,
  sidebarMenuButtonClass,
  sidebarMenuClass,
  sidebarMenuItemClass,
} from './ui/sidebar.ts';

export interface NavSecondaryItem {
  title: string;
  url: string;
  icon: (cls?: string) => TemplateResult;
}

export function navSecondary({ items, class: cls }: { items: NavSecondaryItem[]; class?: string }) {
  return html`
    <div data-slot="sidebar-group" data-sidebar="group" class=${cn(sidebarGroupClass(), cls)}>
      <div data-slot="sidebar-group-content" data-sidebar="group-content" class=${sidebarGroupContentClass()}>
        <ul data-slot="sidebar-menu" data-sidebar="menu" class=${sidebarMenuClass()}>
          ${items.map((item) => html`
            <li data-slot="sidebar-menu-item" data-sidebar="menu-item" class=${sidebarMenuItemClass()}>
              <a href=${item.url} data-slot="sidebar-menu-button" data-sidebar="menu-button" data-size="default" class=${sidebarMenuButtonClass()}>
                ${item.icon()}
                <span>${item.title}</span>
              </a>
            </li>
          `)}
        </ul>
      </div>
    </div>
  `;
}
```

```ts title="components/nav-user.ts"
/**
 * The dashboard-01 user menu: the signed-in user's avatar, name and email,
 * opening an account menu. A fragment helper; the menu is the kit's
 * `<ui-dropdown-menu>`. Ported from shadcn/ui's dashboard-01.
 *
 * The menu items are placeholders. Make "Log out" a form that posts to your
 * sign-out action, and the others links to your account pages.
 */
import { html } from '@webjsdev/core';
import { cn } from '../lib/utils/cn.ts';
import { avatarClass, avatarFallbackClass, avatarImageClass } from './ui/avatar.ts';
import './ui/dropdown-menu.ts';
import {
  sidebarMenuButtonClass,
  sidebarMenuClass,
  sidebarMenuItemClass,
} from './ui/sidebar.ts';
import { BellIcon, CircleUserRoundIcon, CreditCardIcon, EllipsisVerticalIcon, LogOutIcon } from '../lib/utils/icons.ts';

function userAvatar(user: { name: string; avatar: string }) {
  return html`<span data-slot="avatar" data-size="default" class=${cn(avatarClass(), 'h-8 w-8 rounded-lg grayscale')}>
    <span data-slot="avatar-fallback" class=${cn(avatarFallbackClass(), 'rounded-lg')}>VK</span>
    <img data-slot="avatar-image" src=${user.avatar} alt="@vivek" class=${avatarImageClass()}>
  </span>`;
}

function userText(user: { name: string; email: string }) {
  return html`<div class="grid flex-1 text-left text-sm leading-tight">
    <span class="truncate font-medium">${user.name}</span>
    <span class="truncate text-xs text-muted-foreground">${user.email}</span>
  </div>`;
}

export function navUser({ user }: { user: { name: string; email: string; avatar: string } }) {
  return html`
    <ul data-slot="sidebar-menu" data-sidebar="menu" class=${sidebarMenuClass()}>
      <li data-slot="sidebar-menu-item" data-sidebar="menu-item" class=${sidebarMenuItemClass()}>
        <ui-dropdown-menu>
          <ui-dropdown-menu-trigger>
            <button type="button" data-slot="sidebar-menu-button" data-sidebar="menu-button" data-size="lg" class=${cn(sidebarMenuButtonClass({ size: 'lg' }), 'aria-expanded:bg-sidebar-accent aria-expanded:text-sidebar-accent-foreground')}>
              ${userAvatar(user)}
              ${userText(user)}
              ${EllipsisVerticalIcon('ml-auto size-4')}
            </button>
          </ui-dropdown-menu-trigger>
          <ui-dropdown-menu-content class="w-(--radix-dropdown-menu-trigger-width) min-w-56 rounded-lg" side="right" align="end">
            <ui-dropdown-menu-label class="p-0 font-normal">
              <div class="flex items-center gap-2 px-1 py-1.5 text-left text-sm">
                ${userAvatar(user)}
                ${userText(user)}
              </div>
            </ui-dropdown-menu-label>
            <ui-dropdown-menu-separator></ui-dropdown-menu-separator>
            <ui-dropdown-menu-group>
              <ui-dropdown-menu-item>${CircleUserRoundIcon()}Account</ui-dropdown-menu-item>
              <ui-dropdown-menu-item>${CreditCardIcon()}Billing</ui-dropdown-menu-item>
              <ui-dropdown-menu-item>${BellIcon()}Notifications</ui-dropdown-menu-item>
            </ui-dropdown-menu-group>
            <ui-dropdown-menu-separator></ui-dropdown-menu-separator>
            <ui-dropdown-menu-item>${LogOutIcon()}Log out</ui-dropdown-menu-item>
          </ui-dropdown-menu-content>
        </ui-dropdown-menu>
      </li>
    </ul>
  `;
}
```

```ts title="components/site-header.ts"
/**
 * The dashboard-01 site header: the sidebar trigger and the page title, at
 * the height the page sets through `--header-height`. A fragment helper.
 * Ported from shadcn/ui's dashboard-01.
 *
 * Options: `title`, `trigger: false` for a sidebar that does not collapse,
 * `quickCreate` for a "Quick Create" button at the end (`quickCreateIcon` its
 * icon), and `sticky` to pin the header over the scrolling page, as shadcn's
 * examples/dashboard does. The button is a placeholder for your create flow.
 * `github` is the ghost link at the end, shadcn's "GitHub" button pointing at
 * this block's source: point it at your own repository, or pass `false` to
 * leave it out.
 */
import { html } from '@webjsdev/core';
import { cn } from '../lib/utils/cn.ts';
import type { TemplateResult } from '@webjsdev/core';
import { buttonClass } from './ui/button.ts';
import { separatorClass } from './ui/separator.ts';
import { CirclePlusIcon } from '../lib/utils/icons.ts';
import './ui/sidebar.ts';

export interface SiteHeaderOptions {
  title?: string;
  trigger?: boolean;
  quickCreate?: boolean;
  quickCreateIcon?: TemplateResult;
  sticky?: boolean;
  github?: string | false;
}

const GITHUB = 'https://github.com/webjsdev/webjs/tree/main/packages/ui/packages/registry/blocks/dashboard-01';

export function siteHeader(opts: SiteHeaderOptions = {}) {
  const trigger = opts.trigger ?? true;
  const github = opts.github ?? GITHUB;
  return html`
    <header class=${cn('flex h-(--header-height) shrink-0 items-center gap-2 border-b transition-[width,height] ease-linear group-has-data-[collapsible=icon]/sidebar-wrapper:h-(--header-height)', opts.sticky && 'sticky top-0 z-10 bg-background/90')}>
      <div class="flex w-full items-center gap-1 px-4 lg:gap-2 lg:px-6">
        ${trigger ? html`<ui-sidebar-trigger class="-ml-1"></ui-sidebar-trigger>
        <div role="none" data-slot="separator" data-orientation="vertical" class=${cn(separatorClass(), 'mx-2 data-[orientation=vertical]:h-4')}></div>` : ''}
        <h1 class="text-base font-medium">${opts.title ?? 'Documents'}</h1>
        ${opts.quickCreate || github ? html`<div class="ml-auto flex items-center gap-2">
          ${opts.quickCreate ? html`<button type="button" data-slot="button" data-variant="default" data-size="sm" class=${cn(buttonClass({ size: 'sm' }), 'hidden h-7 sm:flex')}>
            ${opts.quickCreateIcon ?? CirclePlusIcon()}
            <span>Quick Create</span>
          </button>` : ''}
          ${github ? html`<a href=${github} rel="noopener noreferrer" target="_blank" data-slot="button" data-variant="ghost" data-size="sm" class=${cn(buttonClass({ variant: 'ghost', size: 'sm' }), 'hidden no-underline sm:flex dark:text-foreground')}>GitHub</a>` : ''}
        </div>` : ''}
      </div>
    </header>
  `;
}
```

```ts title="components/section-cards.ts"
/**
 * The dashboard-01 section cards: four headline metrics, each with its
 * trend badge and a two-line footer. A fragment helper. Ported from
 * shadcn/ui's dashboard-01.
 *
 * The figures are sample data. Compute them on the server (a query in a
 * `'use server'` file) and pass them in.
 */
import { html } from '@webjsdev/core';
import type { TemplateResult } from '@webjsdev/core';
import { cn } from '../lib/utils/cn.ts';
import { badgeClass } from './ui/badge.ts';
import {
  cardActionClass,
  cardClass,
  cardDescriptionClass,
  cardFooterClass,
  cardHeaderClass,
  cardTitleClass,
} from './ui/card.ts';
import { TrendingDownIcon, TrendingUpIcon } from '../lib/utils/icons.ts';

interface Metric {
  label: string;
  value: string;
  change: string;
  trend: (cls?: string) => TemplateResult;
  summary: string;
  detail: string;
}

const metrics: Metric[] = [
  { label: 'Total Revenue', value: '$1,250.00', change: '+12.5%', trend: TrendingUpIcon, summary: 'Trending up this month', detail: 'Visitors for the last 6 months' },
  { label: 'New Customers', value: '1,234', change: '-20%', trend: TrendingDownIcon, summary: 'Down 20% this period', detail: 'Acquisition needs attention' },
  { label: 'Active Accounts', value: '45,678', change: '+12.5%', trend: TrendingUpIcon, summary: 'Strong user retention', detail: 'Engagement exceed targets' },
  { label: 'Growth Rate', value: '4.5%', change: '+4.5%', trend: TrendingUpIcon, summary: 'Steady performance increase', detail: 'Meets growth projections' },
];

export function sectionCards() {
  return html`
    <div class="grid grid-cols-1 gap-4 px-4 *:data-[slot=card]:bg-gradient-to-t *:data-[slot=card]:from-primary/5 *:data-[slot=card]:to-card *:data-[slot=card]:shadow-xs lg:px-6 @xl/main:grid-cols-2 @5xl/main:grid-cols-4 dark:*:data-[slot=card]:bg-card">
      ${metrics.map((m) => html`
        <div data-slot="card" data-size="default" class=${cn(cardClass(), '@container/card')}>
          <div data-slot="card-header" class=${cardHeaderClass()}>
            <div data-slot="card-description" class=${cardDescriptionClass()}>${m.label}</div>
            <div data-slot="card-title" class=${cn(cardTitleClass(), 'text-2xl font-semibold tabular-nums @[250px]/card:text-3xl')}>${m.value}</div>
            <div data-slot="card-action" class=${cardActionClass()}>
              <span data-slot="badge" data-variant="outline" class=${badgeClass({ variant: 'outline' })}>${m.trend()}${m.change}</span>
            </div>
          </div>
          <div data-slot="card-footer" class=${cn(cardFooterClass(), 'flex-col items-start gap-1.5 text-sm')}>
            <div class="line-clamp-1 flex gap-2 font-medium">${m.summary} ${m.trend('size-4')}</div>
            <div class="text-muted-foreground">${m.detail}</div>
          </div>
        </div>
      `)}
    </div>
  `;
}
```

```ts title="components/chart-area-interactive.ts"
/**
 * The dashboard-01 visitors chart: a stacked area chart of desktop and mobile
 * visitors, with a time-range control (a toggle group on a wide card, a
 * select on a narrow one) that narrows it to the last 3 months, 30 days or 7
 * days. Ported from shadcn/ui's dashboard-01.
 *
 * The server draws all three ranges with the kit's `areaChart` and shows the
 * 3-month one, so the first paint is the complete chart and it reads with
 * JavaScript off. The `<dashboard-01-chart-range>` element below only swaps
 * which range is shown and keeps the two controls in step. shadcn also starts
 * a phone on the 7-day range; here a phone starts on 3 months like any other
 * screen, since the server cannot know the width.
 *
 * Options: `range` picks the range shown first (`'90d'` by default), and
 * `tooltipIndex` shows the tooltip at that point from the first paint
 * (Recharts' `defaultIndex`; none by default).
 *
 * The figures are sample data. Query your own on the server and pass them to
 * the chart the same way.
 */
import { WebComponent, html, svg } from '@webjsdev/core';
import { cn } from '../lib/utils/cn.ts';
import {
  cardActionClass,
  cardClass,
  cardContentClass,
  cardDescriptionClass,
  cardHeaderClass,
  cardTitleClass,
} from './ui/card.ts';
import { areaChart, type ChartConfig } from './ui/chart.ts';
import { selectTriggerClass } from './ui/select.ts';
import './ui/select.ts';
import './ui/toggle-group.ts';

export const description = 'An interactive area chart';

const chartData: { date: string; desktop: number; mobile: number }[] = [
  { date: '2024-04-01', desktop: 222, mobile: 150 },
  { date: '2024-04-02', desktop: 97, mobile: 180 },
  { date: '2024-04-03', desktop: 167, mobile: 120 },
  { date: '2024-04-04', desktop: 242, mobile: 260 },
  { date: '2024-04-05', desktop: 373, mobile: 290 },
  { date: '2024-04-06', desktop: 301, mobile: 340 },
  { date: '2024-04-07', desktop: 245, mobile: 180 },
  { date: '2024-04-08', desktop: 409, mobile: 320 },
  { date: '2024-04-09', desktop: 59, mobile: 110 },
  { date: '2024-04-10', desktop: 261, mobile: 190 },
  { date: '2024-04-11', desktop: 327, mobile: 350 },
  { date: '2024-04-12', desktop: 292, mobile: 210 },
  { date: '2024-04-13', desktop: 342, mobile: 380 },
  { date: '2024-04-14', desktop: 137, mobile: 220 },
  { date: '2024-04-15', desktop: 120, mobile: 170 },
  { date: '2024-04-16', desktop: 138, mobile: 190 },
  { date: '2024-04-17', desktop: 446, mobile: 360 },
  { date: '2024-04-18', desktop: 364, mobile: 410 },
  { date: '2024-04-19', desktop: 243, mobile: 180 },
  { date: '2024-04-20', desktop: 89, mobile: 150 },
  { date: '2024-04-21', desktop: 137, mobile: 200 },
  { date: '2024-04-22', desktop: 224, mobile: 170 },
  { date: '2024-04-23', desktop: 138, mobile: 230 },
  { date: '2024-04-24', desktop: 387, mobile: 290 },
  { date: '2024-04-25', desktop: 215, mobile: 250 },
  { date: '2024-04-26', desktop: 75, mobile: 130 },
  { date: '2024-04-27', desktop: 383, mobile: 420 },
  { date: '2024-04-28', desktop: 122, mobile: 180 },
  { date: '2024-04-29', desktop: 315, mobile: 240 },
  { date: '2024-04-30', desktop: 454, mobile: 380 },
  { date: '2024-05-01', desktop: 165, mobile: 220 },
  { date: '2024-05-02', desktop: 293, mobile: 310 },
  { date: '2024-05-03', desktop: 247, mobile: 190 },
  { date: '2024-05-04', desktop: 385, mobile: 420 },
  { date: '2024-05-05', desktop: 481, mobile: 390 },
  { date: '2024-05-06', desktop: 498, mobile: 520 },
  { date: '2024-05-07', desktop: 388, mobile: 300 },
  { date: '2024-05-08', desktop: 149, mobile: 210 },
  { date: '2024-05-09', desktop: 227, mobile: 180 },
  { date: '2024-05-10', desktop: 293, mobile: 330 },
  { date: '2024-05-11', desktop: 335, mobile: 270 },
  { date: '2024-05-12', desktop: 197, mobile: 240 },
  { date: '2024-05-13', desktop: 197, mobile: 160 },
  { date: '2024-05-14', desktop: 448, mobile: 490 },
  { date: '2024-05-15', desktop: 473, mobile: 380 },
  { date: '2024-05-16', desktop: 338, mobile: 400 },
  { date: '2024-05-17', desktop: 499, mobile: 420 },
  { date: '2024-05-18', desktop: 315, mobile: 350 },
  { date: '2024-05-19', desktop: 235, mobile: 180 },
  { date: '2024-05-20', desktop: 177, mobile: 230 },
  { date: '2024-05-21', desktop: 82, mobile: 140 },
  { date: '2024-05-22', desktop: 81, mobile: 120 },
  { date: '2024-05-23', desktop: 252, mobile: 290 },
  { date: '2024-05-24', desktop: 294, mobile: 220 },
  { date: '2024-05-25', desktop: 201, mobile: 250 },
  { date: '2024-05-26', desktop: 213, mobile: 170 },
  { date: '2024-05-27', desktop: 420, mobile: 460 },
  { date: '2024-05-28', desktop: 233, mobile: 190 },
  { date: '2024-05-29', desktop: 78, mobile: 130 },
  { date: '2024-05-30', desktop: 340, mobile: 280 },
  { date: '2024-05-31', desktop: 178, mobile: 230 },
  { date: '2024-06-01', desktop: 178, mobile: 200 },
  { date: '2024-06-02', desktop: 470, mobile: 410 },
  { date: '2024-06-03', desktop: 103, mobile: 160 },
  { date: '2024-06-04', desktop: 439, mobile: 380 },
  { date: '2024-06-05', desktop: 88, mobile: 140 },
  { date: '2024-06-06', desktop: 294, mobile: 250 },
  { date: '2024-06-07', desktop: 323, mobile: 370 },
  { date: '2024-06-08', desktop: 385, mobile: 320 },
  { date: '2024-06-09', desktop: 438, mobile: 480 },
  { date: '2024-06-10', desktop: 155, mobile: 200 },
  { date: '2024-06-11', desktop: 92, mobile: 150 },
  { date: '2024-06-12', desktop: 492, mobile: 420 },
  { date: '2024-06-13', desktop: 81, mobile: 130 },
  { date: '2024-06-14', desktop: 426, mobile: 380 },
  { date: '2024-06-15', desktop: 307, mobile: 350 },
  { date: '2024-06-16', desktop: 371, mobile: 310 },
  { date: '2024-06-17', desktop: 475, mobile: 520 },
  { date: '2024-06-18', desktop: 107, mobile: 170 },
  { date: '2024-06-19', desktop: 341, mobile: 290 },
  { date: '2024-06-20', desktop: 408, mobile: 450 },
  { date: '2024-06-21', desktop: 169, mobile: 210 },
  { date: '2024-06-22', desktop: 317, mobile: 270 },
  { date: '2024-06-23', desktop: 480, mobile: 530 },
  { date: '2024-06-24', desktop: 132, mobile: 180 },
  { date: '2024-06-25', desktop: 141, mobile: 190 },
  { date: '2024-06-26', desktop: 434, mobile: 380 },
  { date: '2024-06-27', desktop: 448, mobile: 490 },
  { date: '2024-06-28', desktop: 149, mobile: 200 },
  { date: '2024-06-29', desktop: 103, mobile: 160 },
  { date: '2024-06-30', desktop: 446, mobile: 400 },
];

const chartConfig = {
  visitors: {
    label: 'Visitors',
  },
  desktop: {
    label: 'Desktop',
    color: 'var(--primary)',
  },
  mobile: {
    label: 'Mobile',
    color: 'var(--primary)',
  },
} satisfies ChartConfig;

export type ChartRange = '90d' | '30d' | '7d';

const RANGES: { value: ChartRange; days: number; label: string }[] = [
  { value: '90d', days: 90, label: 'Last 3 months' },
  { value: '30d', days: 30, label: 'Last 30 days' },
  { value: '7d', days: 7, label: 'Last 7 days' },
];

const DAY = 24 * 60 * 60 * 1000;
const REFERENCE = Date.parse('2024-06-30');

// The dates are calendar dates, so they are read and written in UTC: a server
// west of Greenwich would otherwise print every tick a day early.
const shortDate = (value: unknown) =>
  new Date(String(value)).toLocaleDateString('en-US', { month: 'short', day: 'numeric', timeZone: 'UTC' });

function rangeChart(range: (typeof RANGES)[number], tooltipIndex?: number) {
  const start = REFERENCE - range.days * DAY;
  const data = chartData.filter((item) => Date.parse(item.date) >= start);
  // Gradient ids are per range, since all three charts sit on one page.
  const desktop = `fillDesktop-${range.value}`;
  const mobile = `fillMobile-${range.value}`;
  return areaChart({
    config: chartConfig,
    data,
    title: `Desktop and mobile visitors, ${range.label.toLowerCase()}`,
    class: 'aspect-auto h-[250px] w-full',
    width: 1046,
    height: 250,
    defs: svg`
      <linearGradient id=${desktop} x1="0" y1="0" x2="0" y2="1">
        <stop offset="5%" stop-color="var(--color-desktop)" stop-opacity="1"></stop>
        <stop offset="95%" stop-color="var(--color-desktop)" stop-opacity="0.1"></stop>
      </linearGradient>
      <linearGradient id=${mobile} x1="0" y1="0" x2="0" y2="1">
        <stop offset="5%" stop-color="var(--color-mobile)" stop-opacity="0.8"></stop>
        <stop offset="95%" stop-color="var(--color-mobile)" stop-opacity="0.1"></stop>
      </linearGradient>
    `,
    grid: { vertical: false },
    xAxis: { dataKey: 'date', tickLine: false, axisLine: false, tickMargin: 8, minTickGap: 32, tickFormatter: shortDate },
    tooltip: { cursor: false, indicator: 'dot', labelFormatter: shortDate, defaultIndex: tooltipIndex },
    areas: [
      { dataKey: 'mobile', type: 'natural', fill: `url(#${mobile})`, stroke: 'var(--color-mobile)', stackId: 'a' },
      { dataKey: 'desktop', type: 'natural', fill: `url(#${desktop})`, stroke: 'var(--color-desktop)', stackId: 'a' },
    ],
  });
}

export function chartAreaInteractive(opts: { range?: ChartRange; tooltipIndex?: number } = {}) {
  const initial = RANGES.some((r) => r.value === opts.range) ? opts.range! : '90d';
  return html`
    <dashboard-01-chart-range>
      <div data-slot="card" data-size="default" class=${cn(cardClass(), '@container/card')}>
        <div data-slot="card-header" class=${cardHeaderClass()}>
          <div data-slot="card-title" class=${cardTitleClass()}>Total Visitors</div>
          <div data-slot="card-description" class=${cardDescriptionClass()}>
            <span class="hidden @[540px]/card:block">Total for the last 3 months</span>
            <span class="@[540px]/card:hidden">Last 3 months</span>
          </div>
          <div data-slot="card-action" class=${cardActionClass()}>
            <ui-toggle-group type="single" value=${initial} variant="outline" spacing="0" class="hidden *:data-[slot=toggle-group-item]:px-4! @[767px]/card:flex">
              ${RANGES.map((r) => html`<ui-toggle-group-item value=${r.value}>${r.label}</ui-toggle-group-item>`)}
            </ui-toggle-group>
            <ui-select size="sm">
              <select aria-label="Select a value" class=${cn(selectTriggerClass(), 'flex w-40 **:data-[slot=select-value]:block **:data-[slot=select-value]:truncate @[767px]/card:hidden')}>
                ${RANGES.map((r) => html`<option value=${r.value} ?selected=${r.value === initial}>${r.label}</option>`)}
              </select>
            </ui-select>
          </div>
        </div>
        <div data-slot="card-content" class=${cn(cardContentClass(), 'px-2 pt-4 sm:px-6 sm:pt-6')}>
          ${RANGES.map((r) => html`<div data-range=${r.value} ?hidden=${r.value !== initial}>${rangeChart(r, opts.tooltipIndex)}</div>`)}
        </div>
      </div>
    </dashboard-01-chart-range>
  `;
}

/**
 * `<dashboard-01-chart-range>`: shows the range the toggle group or the select
 * picks, and moves the other control to match. The charts themselves are the
 * server's; nothing is redrawn here.
 */
export class Dashboard01ChartRange extends WebComponent {
  connectedCallback() {
    super.connectedCallback();
    this.addEventListener('ui-value-change', this._onToggle);
    this.addEventListener('change', this._onSelect);
  }

  disconnectedCallback() {
    this.removeEventListener('ui-value-change', this._onToggle);
    this.removeEventListener('change', this._onSelect);
    super.disconnectedCallback();
  }

  _show(value: string): void {
    if (!RANGES.some((r) => r.value === value)) return;
    for (const panel of Array.from(this.querySelectorAll<HTMLElement>('[data-range]'))) {
      panel.hidden = panel.dataset.range !== value;
    }
    const group = this.querySelector('ui-toggle-group') as (HTMLElement & { value: string }) | null;
    if (group && group.value !== value) group.value = value;
    const select = this.querySelector<HTMLSelectElement>('ui-select select');
    if (select && select.value !== value) {
      select.value = value;
      select.dispatchEvent(new Event('change', { bubbles: true }));
    }
  }

  // A single toggle group can be emptied by pressing the active item; the
  // range then stays where it was, so put the pressed state back.
  _onToggle = (e: Event): void => {
    const target = e.target as Element;
    if (target.tagName !== 'UI-TOGGLE-GROUP') return;
    const value = String((e as CustomEvent<{ value: string }>).detail?.value ?? '');
    if (value) this._show(value);
    else this._show(this.querySelector<HTMLElement>('[data-range]:not([hidden])')?.dataset.range ?? '90d');
  };

  _onSelect = (e: Event): void => {
    const select = e.target as HTMLSelectElement;
    if (select.tagName === 'SELECT') this._show(select.value);
  };

  render() {
    return html`<slot></slot>`;
  }
}
Dashboard01ChartRange.register('dashboard-01-chart-range');
```

```ts title="components/data-table.ts"
/**
 * The dashboard-01 data table: the document's outline sections under a row of
 * view tabs, with a columns menu, row selection, drag-to-reorder, inline
 * target and limit fields, a reviewer picker, a row actions menu, pagination,
 * and a drawer that opens a section for editing. Ported from shadcn/ui's
 * dashboard-01, which builds it on TanStack Table and dnd-kit.
 *
 * The server renders the first page of 10 rows, so the first paint is
 * shadcn's and reads with JavaScript off, and the document holds only the
 * rows on screen. Every row rides on the element's `rows` attribute, and
 * `<dashboard-01-data-table>` (below) renders the current page's rows from
 * it on each change, with no third-party code: the page buttons and the page
 * size, the row checkboxes with select-all and the "n of m row(s) selected"
 * count, the columns menu, dragging a row by its handle (or moving it with
 * the arrow keys while the handle has focus), the view select on a narrow
 * card, and the one drawer that every row's title fills and opens. The order,
 * the selection and the edited cells live in the element, so they hold across
 * pages.
 *
 * The forms have no action yet. Bind a server action from a `'use server'`
 * file to the inline target and limit forms and to the drawer's form
 * (`<form action=${saveSection}>`), and render the rows from your own query
 * in place of `dashboardData`. Until then the inline forms submit as a GET
 * back to the page.
 */
import { WebComponent, html, prop, render, repeat, nothing } from '@webjsdev/core';
import { cn } from '../lib/utils/cn.ts';
import { badgeClass } from './ui/badge.ts';
import { buttonClass } from './ui/button.ts';
import { areaChart, type ChartConfig } from './ui/chart.ts';
import { checkboxClass } from './ui/checkbox.ts';
import {
  drawerDescriptionClass,
  drawerFooterClass,
  drawerHeaderClass,
  drawerTitleClass,
} from './ui/drawer.ts';
import { inputClass } from './ui/input.ts';
import { labelClass } from './ui/label.ts';
import { selectTriggerClass } from './ui/select.ts';
import { separatorClass } from './ui/separator.ts';
import {
  tableBodyClass,
  tableCellClass,
  tableClass,
  tableContainerClass,
  tableHeadClass,
  tableHeaderClass,
  tableRowClass,
} from './ui/table.ts';
import './ui/checkbox.ts';
import './ui/drawer.ts';
import './ui/dropdown-menu.ts';
import './ui/select.ts';
import './ui/tabs.ts';
import type { DashboardRow } from './dashboard-data.ts';
import { ChevronDownIcon, ChevronLeftIcon, ChevronRightIcon, ChevronsLeftIcon, ChevronsRightIcon, CircleCheckIcon, Columns3Icon, EllipsisVerticalIcon, GripVerticalIcon, LoaderIcon, PlusIcon, TrendingUpIcon } from '../lib/utils/icons.ts';

/** The columns the columns menu can hide, shadcn's hideable accessor columns. */
const HIDEABLE = ['type', 'status', 'target', 'limit', 'reviewer'];

const VIEWS = [
  { value: 'outline', label: 'Outline' },
  { value: 'past-performance', label: 'Past Performance', count: 3 },
  { value: 'key-personnel', label: 'Key Personnel', count: 2 },
  { value: 'focus-documents', label: 'Focus Documents' },
];

const PAGE_SIZES = [10, 20, 30, 40, 50];

const SECTION_TYPES = ['Table of Contents', 'Executive Summary', 'Technical Approach', 'Design', 'Capabilities', 'Focus Documents', 'Narrative', 'Cover Page'];
const STATUSES = ['Done', 'In Progress', 'Not Started'];
const REVIEWERS = ['Eddie Lake', 'Jamik Tashpulatov', 'Emily Whalen'];

const INLINE_INPUT = 'h-8 w-16 border-transparent bg-transparent text-right shadow-none hover:bg-input/30 focus-visible:border focus-visible:bg-background dark:bg-transparent dark:hover:bg-input/30 dark:focus-visible:bg-input/30';

const head = (cls = '') => cn(tableHeadClass(), cls);
const cell = (cls = '') => cn(tableCellClass(), cls);

/** What the row edits in place: the inline fields and the reviewer pick. */
type RowEdit = Partial<Pick<DashboardRow, 'target' | 'limit' | 'reviewer'>>;

/** How one row renders: selected or not, its edits, the hidden columns. */
interface RowState {
  selected: boolean;
  edit: RowEdit;
  hidden: ReadonlySet<string>;
}

const FIRST_PAINT: RowState = { selected: false, edit: {}, hidden: new Set() };

/** One inline field (target or limit), a form of its own as in shadcn. */
function inlineField(row: DashboardRow, key: 'target' | 'limit', label: string, edit: RowEdit) {
  return html`<form>
    <label for=${`${row.id}-${key}`} data-slot="label" class=${cn(labelClass(), 'sr-only')}>${label}</label>
    <input id=${`${row.id}-${key}`} name=${key} value=${edit[key] ?? row[key]} data-row-edit=${key} data-slot="input" class=${cn(inputClass(), INLINE_INPUT)}>
  </form>`;
}

function reviewerCell(row: DashboardRow, edit: RowEdit) {
  if (row.reviewer !== 'Assign reviewer') return row.reviewer;
  const picked = edit.reviewer ?? '';
  return html`
    <label for=${`${row.id}-reviewer`} data-slot="label" class=${cn(labelClass(), 'sr-only')}>Reviewer</label>
    <ui-select size="sm" placeholder="Assign reviewer">
      <select id=${`${row.id}-reviewer`} name="reviewer" data-row-edit="reviewer" class=${cn(selectTriggerClass(), 'w-38 **:data-[slot=select-value]:block **:data-[slot=select-value]:truncate')}>
        <option value="" disabled hidden ?selected=${!picked}>Assign reviewer</option>
        <option value="Eddie Lake" ?selected=${picked === 'Eddie Lake'}>Eddie Lake</option>
        <option value="Jamik Tashpulatov" ?selected=${picked === 'Jamik Tashpulatov'}>Jamik Tashpulatov</option>
      </select>
    </ui-select>
  `;
}

function row(r: DashboardRow, state: RowState) {
  const { selected, edit, hidden } = state;
  return html`
    <tr data-slot="table-row" data-row-id=${String(r.id)} data-dragging="false" data-state=${selected ? 'selected' : nothing} class=${cn(tableRowClass(), 'relative z-0 data-[dragging=true]:z-10 data-[dragging=true]:opacity-80')}>
      <td data-slot="table-cell" class=${cell()}>
        <button type="button" draggable="true" data-drag-handle data-slot="button" data-variant="ghost" data-size="icon" class=${cn(buttonClass({ variant: 'ghost', size: 'icon' }), 'size-7 cursor-grab text-muted-foreground hover:bg-transparent')}>
          ${GripVerticalIcon('size-3 text-muted-foreground')}
          <span class="sr-only">Drag to reorder</span>
        </button>
      </td>
      <td data-slot="table-cell" class=${cell()}>
        <div class="flex items-center justify-center">
          ${state === FIRST_PAINT
            // The first paint is part of the PAGE's template (the page never
            // hydrates), so it states the checkbox as an attribute; a page
            // template may not carry a `.prop` binding. The element's own
            // repaints set the live property, which a box the user has
            // toggled still follows.
            ? html`<input type="checkbox" data-slot="checkbox" data-row-select class=${checkboxClass()} aria-label="Select row" ?checked=${selected}>`
            : html`<input type="checkbox" data-slot="checkbox" data-row-select class=${checkboxClass()} aria-label="Select row" .checked=${selected}>`}
        </div>
      </td>
      <td data-slot="table-cell" class=${cell()}>
        <button type="button" data-row-open data-slot="button" data-variant="link" class=${cn(buttonClass({ variant: 'link' }), 'w-fit px-0 text-left text-foreground')}>${r.header}</button>
      </td>
      <td data-slot="table-cell" data-column="type" class=${cell()} ?hidden=${hidden.has('type')}>
        <div class="w-32">
          <span data-slot="badge" data-variant="outline" class=${cn(badgeClass({ variant: 'outline' }), 'px-1.5 text-muted-foreground')}>${r.type}</span>
        </div>
      </td>
      <td data-slot="table-cell" data-column="status" class=${cell()} ?hidden=${hidden.has('status')}>
        <span data-slot="badge" data-variant="outline" class=${cn(badgeClass({ variant: 'outline' }), 'px-1.5 text-muted-foreground')}>
          ${r.status === 'Done' ? CircleCheckIcon('fill-green-500 dark:fill-green-400') : LoaderIcon()}
          ${r.status}
        </span>
      </td>
      <td data-slot="table-cell" data-column="target" class=${cell()} ?hidden=${hidden.has('target')}>${inlineField(r, 'target', 'Target', edit)}</td>
      <td data-slot="table-cell" data-column="limit" class=${cell()} ?hidden=${hidden.has('limit')}>${inlineField(r, 'limit', 'Limit', edit)}</td>
      <td data-slot="table-cell" data-column="reviewer" class=${cell()} ?hidden=${hidden.has('reviewer')}>${reviewerCell(r, edit)}</td>
      <td data-slot="table-cell" class=${cell()}>
        <ui-dropdown-menu>
          <ui-dropdown-menu-trigger>
            <button type="button" data-slot="button" data-variant="ghost" data-size="icon" class=${cn(buttonClass({ variant: 'ghost', size: 'icon' }), 'flex size-8 text-muted-foreground aria-expanded:bg-muted')}>
              ${EllipsisVerticalIcon()}
              <span class="sr-only">Open menu</span>
            </button>
          </ui-dropdown-menu-trigger>
          <ui-dropdown-menu-content align="end" class="w-32">
            <ui-dropdown-menu-item>Edit</ui-dropdown-menu-item>
            <ui-dropdown-menu-item>Make a copy</ui-dropdown-menu-item>
            <ui-dropdown-menu-item>Favorite</ui-dropdown-menu-item>
            <ui-dropdown-menu-separator></ui-dropdown-menu-separator>
            <ui-dropdown-menu-item variant="destructive">Delete</ui-dropdown-menu-item>
          </ui-dropdown-menu-content>
        </ui-dropdown-menu>
      </td>
    </tr>
  `;
}

/** The body's rows, keyed by id so a reorder moves the row's own element. */
const bodyRows = (rows: DashboardRow[], stateOf: (r: DashboardRow) => RowState) =>
  html`${repeat(rows, (r) => r.id, (r) => row(r, stateOf(r)))}`;

const pageButton = (action: string, label: string, icon: unknown, cls: string, disabled: boolean) =>
  html`<button type="button" data-page=${action} data-slot="button" data-variant="outline" class=${cn(buttonClass({ variant: 'outline', size: 'icon' }), cls)} ?disabled=${disabled}>
    <span class="sr-only">${label}</span>${icon}
  </button>`;

// The drawer's chart, shadcn's TableCellViewer chart.
const drawerChartData = [
  { month: 'January', desktop: 186, mobile: 80 },
  { month: 'February', desktop: 305, mobile: 200 },
  { month: 'March', desktop: 237, mobile: 120 },
  { month: 'April', desktop: 73, mobile: 190 },
  { month: 'May', desktop: 209, mobile: 130 },
  { month: 'June', desktop: 214, mobile: 140 },
];

const drawerChartConfig = {
  desktop: { label: 'Desktop', color: 'var(--primary)' },
  mobile: { label: 'Mobile', color: 'var(--primary)' },
} satisfies ChartConfig;

function drawerSelect(id: string, label: string, placeholder: string, options: string[], current: string) {
  return html`<div class="flex flex-col gap-3">
    <label for=${id} data-slot="label" class=${labelClass()}>${label}</label>
    <ui-select placeholder=${placeholder}>
      <select id=${id} name=${id.replace('drawer-', '')} class=${cn(selectTriggerClass(), 'w-full')}>
        <option value="" disabled hidden ?selected=${!options.includes(current)}>${placeholder}</option>
        ${options.map((o) => html`<option value=${o} ?selected=${o === current}>${o}</option>`)}
      </select>
    </ui-select>
  </div>`;
}

function drawerInput(id: string, label: string, value: string) {
  return html`<div class="flex flex-col gap-3">
    <label for=${id} data-slot="label" class=${labelClass()}>${label}</label>
    <input id=${id} name=${id.replace('drawer-', '')} value=${value} data-slot="input" class=${inputClass()}>
  </div>`;
}

/**
 * shadcn's TableCellViewer, rendered once: every row's title opens this
 * drawer, and the element fills it with that row's values first. shadcn hides
 * the chart on a phone, where the drawer comes up from the bottom; here it
 * always slides in from the right and the chart hides below md.
 */
function rowDrawer(first: DashboardRow) {
  return html`
    <ui-drawer data-row-drawer>
      <ui-drawer-content direction="right">
        <div data-slot="drawer-header" class=${cn(drawerHeaderClass(), 'gap-1')}>
          <h2 data-slot="drawer-title" data-drawer-title class=${drawerTitleClass()}>${first.header}</h2>
          <p data-slot="drawer-description" class=${drawerDescriptionClass()}>Showing total visitors for the last 6 months</p>
        </div>
        <div class="flex flex-col gap-4 overflow-y-auto px-4 text-sm">
          <div class="hidden flex-col gap-4 md:flex">
            ${areaChart({
              config: drawerChartConfig,
              data: drawerChartData,
              title: 'Desktop and mobile visitors, January to June',
              margin: { left: 0, right: 10 },
              grid: { vertical: false },
              xAxis: { dataKey: 'month', tickLine: false, axisLine: false, tickMargin: 8, tickFormatter: (value) => String(value).slice(0, 3), hide: true },
              tooltip: { cursor: false, indicator: 'dot' },
              areas: [
                { dataKey: 'mobile', type: 'natural', fill: 'var(--color-mobile)', fillOpacity: 0.6, stroke: 'var(--color-mobile)', stackId: 'a' },
                { dataKey: 'desktop', type: 'natural', fill: 'var(--color-desktop)', fillOpacity: 0.4, stroke: 'var(--color-desktop)', stackId: 'a' },
              ],
            })}
            <div role="none" data-slot="separator" data-orientation="horizontal" class=${separatorClass()}></div>
            <div class="grid gap-2">
              <div class="flex gap-2 leading-none font-medium">Trending up by 5.2% this month ${TrendingUpIcon('size-4')}</div>
              <div class="text-muted-foreground">Showing total visitors for the last 6 months. This is just some random text to test the layout. It spans multiple lines and should wrap around.</div>
            </div>
            <div role="none" data-slot="separator" data-orientation="horizontal" class=${separatorClass()}></div>
          </div>
          <form id="drawer-form" class="flex flex-col gap-4">
            ${drawerInput('drawer-header', 'Header', first.header)}
            <div class="grid grid-cols-2 gap-4">
              ${drawerSelect('drawer-type', 'Type', 'Select a type', SECTION_TYPES, first.type)}
              ${drawerSelect('drawer-status', 'Status', 'Select a status', STATUSES, first.status)}
            </div>
            <div class="grid grid-cols-2 gap-4">
              ${drawerInput('drawer-target', 'Target', first.target)}
              ${drawerInput('drawer-limit', 'Limit', first.limit)}
            </div>
            ${drawerSelect('drawer-reviewer', 'Reviewer', 'Select a reviewer', REVIEWERS, first.reviewer)}
          </form>
        </div>
        <div data-slot="drawer-footer" class=${drawerFooterClass()}>
          <button type="submit" form="drawer-form" data-slot="button" class=${buttonClass()}>Submit</button>
          <ui-drawer-close><button type="button" data-slot="button" data-variant="outline" class=${cn(buttonClass({ variant: 'outline' }), 'w-full')}>Done</button></ui-drawer-close>
        </div>
      </ui-drawer-content>
    </ui-drawer>
  `;
}

export function dataTable({ data }: { data: DashboardRow[] }) {
  const pageCount = Math.max(1, Math.ceil(data.length / PAGE_SIZES[0]));
  return html`
    <dashboard-01-data-table rows=${JSON.stringify(data)}>
      <ui-tabs value="outline" class="w-full flex-col justify-start gap-6">
        <div class="flex items-center justify-between px-4 lg:px-6">
          <label for="view-selector" data-slot="label" class=${cn(labelClass(), 'sr-only')}>View</label>
          <ui-select size="sm" placeholder="Select a view">
            <select id="view-selector" data-view-select class=${cn(selectTriggerClass(), 'flex w-fit @4xl/main:hidden')}>
              ${VIEWS.map((v) => html`<option value=${v.value} ?selected=${v.value === 'outline'}>${v.label}</option>`)}
            </select>
          </ui-select>
          <ui-tabs-list class="hidden **:data-[slot=badge]:size-5 **:data-[slot=badge]:rounded-full **:data-[slot=badge]:bg-muted-foreground/30 **:data-[slot=badge]:px-1 @4xl/main:flex">
            ${VIEWS.map((v) => html`<ui-tabs-trigger value=${v.value}>${v.label}${v.count ? html` <span data-slot="badge" data-variant="secondary" class=${badgeClass({ variant: 'secondary' })}>${v.count}</span>` : ''}</ui-tabs-trigger>`)}
          </ui-tabs-list>
          <div class="flex items-center gap-2">
            <ui-dropdown-menu>
              <ui-dropdown-menu-trigger>
                <button type="button" data-slot="button" data-variant="outline" data-size="sm" class=${buttonClass({ variant: 'outline', size: 'sm' })}>
                  ${Columns3Icon()}
                  Columns
                  ${ChevronDownIcon()}
                </button>
              </ui-dropdown-menu-trigger>
              <ui-dropdown-menu-content align="end" class="w-32">
                ${HIDEABLE.map((c) => html`<ui-dropdown-menu-item type="checkbox" value=${c} checked data-column-toggle class="capitalize">${c}</ui-dropdown-menu-item>`)}
              </ui-dropdown-menu-content>
            </ui-dropdown-menu>
            <button type="button" data-slot="button" data-variant="outline" data-size="sm" class=${buttonClass({ variant: 'outline', size: 'sm' })}>
              ${PlusIcon()}
              <span class="hidden lg:inline">Add Section</span>
            </button>
          </div>
        </div>
        <ui-tabs-content value="outline" class="relative flex flex-col gap-4 overflow-auto px-4 lg:px-6">
          <div class="overflow-hidden rounded-lg border">
            <div data-slot="table-container" class=${tableContainerClass()}>
              <table data-slot="table" class=${tableClass()}>
                <thead data-slot="table-header" class=${cn(tableHeaderClass(), 'sticky top-0 z-10 bg-muted')}>
                  <tr data-slot="table-row" class=${tableRowClass()}>
                    <th scope="col" data-slot="table-head" class=${head()}><span class="sr-only">Drag to reorder</span></th>
                    <th scope="col" data-slot="table-head" class=${head()}>
                      <div class="flex items-center justify-center">
                        <input type="checkbox" data-slot="checkbox" data-select-all class=${checkboxClass()} aria-label="Select all">
                      </div>
                    </th>
                    <th scope="col" data-slot="table-head" class=${head()}>Header</th>
                    <th scope="col" data-slot="table-head" data-column="type" class=${head()}>Section Type</th>
                    <th scope="col" data-slot="table-head" data-column="status" class=${head()}>Status</th>
                    <th scope="col" data-slot="table-head" data-column="target" class=${head()}><div class="w-full text-right">Target</div></th>
                    <th scope="col" data-slot="table-head" data-column="limit" class=${head()}><div class="w-full text-right">Limit</div></th>
                    <th scope="col" data-slot="table-head" data-column="reviewer" class=${head()}>Reviewer</th>
                    <th scope="col" data-slot="table-head" class=${head()}><span class="sr-only">Actions</span></th>
                  </tr>
                </thead>
                <tbody data-slot="table-body" data-rows class=${cn(tableBodyClass(), '**:data-[slot=table-cell]:first:w-8')}>
                  ${data.length
                    ? bodyRows(data.slice(0, PAGE_SIZES[0]), () => FIRST_PAINT)
                    : html`<tr data-slot="table-row" class=${tableRowClass()}><td colspan="9" data-slot="table-cell" class=${cell('h-24 text-center')}>No results.</td></tr>`}
                </tbody>
              </table>
            </div>
          </div>
          <div class="flex items-center justify-between px-4">
            <div class="hidden flex-1 text-sm text-muted-foreground lg:flex" aria-live="polite">
              <span><span data-selected-count>0</span> of <span data-row-count>${data.length}</span> row(s) selected.</span>
            </div>
            <div class="flex w-full items-center gap-8 lg:w-fit">
              <div class="hidden items-center gap-2 lg:flex">
                <label for="rows-per-page" data-slot="label" class=${cn(labelClass(), 'text-sm font-medium')}>Rows per page</label>
                <ui-select size="sm">
                  <select id="rows-per-page" data-page-size class=${cn(selectTriggerClass(), 'w-20')}>
                    ${PAGE_SIZES.map((n) => html`<option value=${String(n)} ?selected=${n === PAGE_SIZES[0]}>${n}</option>`)}
                  </select>
                </ui-select>
              </div>
              <div class="flex w-fit items-center justify-center text-sm font-medium" data-page-label>Page 1 of ${pageCount}</div>
              <div class="ml-auto flex items-center gap-2 lg:ml-0">
                ${pageButton('first', 'Go to first page', ChevronsLeftIcon(), 'hidden h-8 w-8 p-0 lg:flex', true)}
                ${pageButton('previous', 'Go to previous page', ChevronLeftIcon(), 'size-8', true)}
                ${pageButton('next', 'Go to next page', ChevronRightIcon(), 'size-8', pageCount <= 1)}
                ${pageButton('last', 'Go to last page', ChevronsRightIcon(), 'hidden size-8 lg:flex', pageCount <= 1)}
              </div>
            </div>
          </div>
        </ui-tabs-content>
        ${VIEWS.slice(1).map((v) => html`<ui-tabs-content value=${v.value} class="flex flex-col px-4 lg:px-6">
          <div class="aspect-video w-full flex-1 rounded-lg border border-dashed"></div>
        </ui-tabs-content>`)}
      </ui-tabs>
      ${data.length ? rowDrawer(data[0]) : ''}
    </dashboard-01-data-table>
  `;
}

type Valued = HTMLElement & { value: string };
type Openable = HTMLElement & { open: boolean };

/**
 * `<dashboard-01-data-table>`: the table's behaviour. It holds every row (the
 * `rows` attribute the server writes) in the order the reader set, with the
 * selection and the edited cells, and renders the current page's rows into
 * the body on each page, page-size, reorder, selection and column change, so
 * the document only ever holds one page.
 */
export class Dashboard01DataTable extends WebComponent({
  rows: prop<DashboardRow[]>(Array),
}) {
  _pageIndex = 0;
  _pageSize = PAGE_SIZES[0];
  _order: DashboardRow[] | null = null;
  _selected = new Set<number>();
  _edits = new Map<number, RowEdit>();
  _hidden = new Set<string>();
  _dragged: number | null = null;

  constructor() {
    super();
    this.rows = [];
  }

  connectedCallback() {
    super.connectedCallback();
    this.addEventListener('change', this._onChange);
    this.addEventListener('input', this._onInput);
    this.addEventListener('click', this._onClick);
    this.addEventListener('ui-item-select', this._onItemSelect);
    this.addEventListener('ui-value-change', this._onTabs);
    this.addEventListener('dragstart', this._onDragStart);
    this.addEventListener('dragover', this._onDragOver);
    this.addEventListener('dragend', this._onDragEnd);
    this.addEventListener('keydown', this._onKeyDown);
  }

  disconnectedCallback() {
    this.removeEventListener('change', this._onChange);
    this.removeEventListener('input', this._onInput);
    this.removeEventListener('click', this._onClick);
    this.removeEventListener('ui-item-select', this._onItemSelect);
    this.removeEventListener('ui-value-change', this._onTabs);
    this.removeEventListener('dragstart', this._onDragStart);
    this.removeEventListener('dragover', this._onDragOver);
    this.removeEventListener('dragend', this._onDragEnd);
    this.removeEventListener('keydown', this._onKeyDown);
    super.disconnectedCallback();
  }

  /** Every row, in the reader's order. */
  _all(): DashboardRow[] {
    return (this._order ??= [...(this.rows || [])]);
  }

  _pageCount(): number {
    return Math.max(1, Math.ceil(this._all().length / this._pageSize));
  }

  _pageRows(): DashboardRow[] {
    const start = this._pageIndex * this._pageSize;
    return this._all().slice(start, start + this._pageSize);
  }

  _rowId(el: Element | null): number | null {
    const id = el?.closest('tr[data-row-id]')?.getAttribute('data-row-id');
    return id == null ? null : Number(id);
  }

  _stateOf = (r: DashboardRow): RowState => ({
    selected: this._selected.has(r.id),
    edit: this._edits.get(r.id) ?? {},
    hidden: this._hidden,
  });

  /** Render the current page's rows, then the pager and the selection text. */
  _update(): void {
    const all = this._all();
    const pageCount = this._pageCount();
    this._pageIndex = Math.min(Math.max(0, this._pageIndex), pageCount - 1);
    const body = this.querySelector<HTMLElement>('tbody[data-rows]');
    if (body && all.length) render(bodyRows(this._pageRows(), this._stateOf), body);
    const label = this.querySelector('[data-page-label]');
    if (label) label.textContent = `Page ${this._pageIndex + 1} of ${pageCount}`;
    const atStart = this._pageIndex === 0;
    const atEnd = this._pageIndex >= pageCount - 1;
    for (const b of Array.from(this.querySelectorAll<HTMLButtonElement>('button[data-page]'))) {
      b.disabled = b.dataset.page === 'first' || b.dataset.page === 'previous' ? atStart : atEnd;
    }
    const count = this.querySelector('[data-selected-count]');
    if (count) count.textContent = String(this._selected.size);
    const total = this.querySelector('[data-row-count]');
    if (total) total.textContent = String(all.length);
    const box = this.querySelector<HTMLInputElement>('input[data-select-all]');
    if (box) {
      const page = this._pageRows().map((r) => this._selected.has(r.id));
      box.checked = page.length > 0 && page.every(Boolean);
      box.indeterminate = !box.checked && page.some(Boolean);
    }
  }

  _onChange = (e: Event): void => {
    const t = e.target as HTMLInputElement | HTMLSelectElement;
    if (t.matches('input[data-select-all]')) {
      for (const r of this._pageRows()) {
        if ((t as HTMLInputElement).checked) this._selected.add(r.id);
        else this._selected.delete(r.id);
      }
      this._update();
    } else if (t.matches('input[data-row-select]')) {
      const id = this._rowId(t);
      if (id != null) {
        if ((t as HTMLInputElement).checked) this._selected.add(id);
        else this._selected.delete(id);
      }
      this._update();
    } else if (t.matches('select[data-row-edit]')) {
      this._edit(t);
    } else if (t.matches('select[data-page-size]')) {
      this._pageSize = Number(t.value) || PAGE_SIZES[0];
      this._pageIndex = 0;
      this._update();
    } else if (t.matches('select[data-view-select]')) {
      const tabs = this.querySelector('ui-tabs') as Valued | null;
      if (tabs && tabs.value !== t.value) tabs.value = t.value;
    }
  };

  // An edited cell is kept with its row, so it holds across pages.
  _onInput = (e: Event): void => {
    const t = e.target as HTMLInputElement;
    if (t.matches?.('input[data-row-edit]')) this._edit(t);
  };

  _edit(field: HTMLInputElement | HTMLSelectElement): void {
    const id = this._rowId(field);
    const key = field.dataset.rowEdit as keyof RowEdit | undefined;
    if (id == null || !key) return;
    this._edits.set(id, { ...this._edits.get(id), [key]: field.value });
  }

  // A tab picked on a wide card moves the narrow card's view select with it.
  _onTabs = (e: Event): void => {
    if ((e.target as Element).tagName !== 'UI-TABS') return;
    const value = String((e as CustomEvent<{ value: string }>).detail?.value ?? '');
    const select = this.querySelector<HTMLSelectElement>('select[data-view-select]');
    if (select && value && select.value !== value) {
      select.value = value;
      select.dispatchEvent(new Event('change', { bubbles: true }));
    }
  };

  _onClick = (e: Event): void => {
    const button = (e.target as Element).closest?.('button');
    if (!button || !this.contains(button)) return;
    const page = button.dataset.page;
    if (page) {
      const last = this._pageCount() - 1;
      this._pageIndex = page === 'first' ? 0 : page === 'previous' ? this._pageIndex - 1 : page === 'next' ? this._pageIndex + 1 : last;
      this._update();
    } else if (button.hasAttribute('data-row-open')) {
      this._openDrawer(button.closest('tr'));
    }
  };

  // The columns menu: each checkbox item shows or hides its column, the
  // header cell here and the body cells on every render.
  _onItemSelect = (e: Event): void => {
    const item = e.target as HTMLElement;
    if (!item.hasAttribute('data-column-toggle')) return;
    const { value, checked } = (e as CustomEvent<{ value: string; checked: boolean }>).detail;
    if (checked) this._hidden.delete(value);
    else this._hidden.add(value);
    for (const c of Array.from(this.querySelectorAll<HTMLElement>(`[data-column="${value}"]`))) c.hidden = !checked;
    this._update();
  };

  /** Fill the shared drawer with one row's values and open it. */
  _openDrawer(row: HTMLTableRowElement | null): void {
    const drawer = this.querySelector('ui-drawer[data-row-drawer]') as Openable | null;
    const id = this._rowId(row);
    const r = this._all().find((x) => x.id === id);
    if (!r || !drawer) return;
    const edit = this._edits.get(r.id) ?? {};
    const values: Record<string, string> = {
      'drawer-header': r.header,
      'drawer-type': r.type,
      'drawer-status': r.status,
      'drawer-target': edit.target ?? r.target,
      'drawer-limit': edit.limit ?? r.limit,
      'drawer-reviewer': edit.reviewer ?? (r.reviewer === 'Assign reviewer' ? '' : r.reviewer),
    };
    const title = drawer.querySelector('[data-drawer-title]');
    if (title) title.textContent = r.header;
    for (const [field, value] of Object.entries(values)) {
      const el = drawer.querySelector<HTMLInputElement | HTMLSelectElement>(`#${field}`);
      if (!el) continue;
      el.value = value;
      if (el instanceof HTMLSelectElement) el.dispatchEvent(new Event('change', { bubbles: true }));
    }
    drawer.open = true;
  }

  /** Move the row with id `id` to `index` in the full order and re-render. */
  _move(id: number, index: number): void {
    const all = this._all();
    const from = all.findIndex((r) => r.id === id);
    if (from < 0) return;
    const to = Math.min(Math.max(0, index), all.length - 1);
    if (from === to) return;
    const [moved] = all.splice(from, 1);
    all.splice(to, 0, moved);
    this._update();
  }

  _onDragStart = (e: DragEvent): void => {
    const handle = (e.target as Element).closest?.('[data-drag-handle]');
    const row = handle?.closest('tr') as HTMLTableRowElement | null;
    const id = this._rowId(row);
    if (!row || id == null) return;
    this._dragged = id;
    row.dataset.dragging = 'true';
    if (e.dataTransfer) {
      e.dataTransfer.effectAllowed = 'move';
      e.dataTransfer.setData('text/plain', String(id));
      e.dataTransfer.setDragImage(row, 16, 16);
    }
  };

  // Rows move within the body only, the vertical-axis restriction shadcn sets.
  _onDragOver = (e: DragEvent): void => {
    const dragged = this._dragged;
    const over = (e.target as Element).closest?.('tbody[data-rows] > tr[data-row-id]') as HTMLTableRowElement | null;
    const overId = this._rowId(over);
    if (dragged == null || !over || overId == null) return;
    e.preventDefault();
    if (overId === dragged) return;
    const box = over.getBoundingClientRect();
    const all = this._all();
    const from = all.findIndex((r) => r.id === dragged);
    let to = all.findIndex((r) => r.id === overId);
    if (e.clientY > box.top + box.height / 2) to += 1;
    if (from < to) to -= 1;
    this._move(dragged, to);
  };

  _onDragEnd = (): void => {
    const row = this._dragged == null ? null : this.querySelector<HTMLElement>(`tr[data-row-id="${this._dragged}"]`);
    if (row) row.dataset.dragging = 'false';
    this._dragged = null;
  };

  // The keyboard way to reorder: the arrow keys move the row whose handle has
  // focus, as dnd-kit's keyboard sensor does, across pages too.
  _onKeyDown = (e: KeyboardEvent): void => {
    if (e.key !== 'ArrowUp' && e.key !== 'ArrowDown') return;
    const handle = (e.target as Element).closest?.('[data-drag-handle]') as HTMLElement | null;
    const id = this._rowId(handle);
    if (!handle || id == null) return;
    e.preventDefault();
    const index = this._all().findIndex((r) => r.id === id) + (e.key === 'ArrowUp' ? -1 : 1);
    if (index < 0 || index >= this._all().length) return;
    this._pageIndex = Math.floor(index / this._pageSize);
    this._move(id, index);
    this.querySelector<HTMLElement>(`tr[data-row-id="${id}"] [data-drag-handle]`)?.focus();
  };

  render() {
    return html`<slot></slot>`;
  }
}
Dashboard01DataTable.register('dashboard-01-data-table');
```

```ts title="components/dashboard-data.ts"
/**
 * The dashboard-01 sample data: the outline sections the data table lists.
 * Installed by `npx @webjsdev/ui add dashboard-01` at
 * `components/dashboard-data.ts`. Replace it with your own rows, typically a
 * query in a `'use server'` file whose result the page passes to
 * `dataTable({ data })`. Ported from shadcn/ui's dashboard-01 data.json.
 */

/** One row of the table, shadcn's zod `schema` as a type. */
export interface DashboardRow {
  id: number;
  header: string;
  type: string;
  status: string;
  target: string;
  limit: string;
  reviewer: string;
}

export const dashboardData: DashboardRow[] = [
  { id: 1, header: 'Cover page', type: 'Cover page', status: 'In Process', target: '18', limit: '5', reviewer: 'Eddie Lake' },
  { id: 2, header: 'Table of contents', type: 'Table of contents', status: 'Done', target: '29', limit: '24', reviewer: 'Eddie Lake' },
  { id: 3, header: 'Executive summary', type: 'Narrative', status: 'Done', target: '10', limit: '13', reviewer: 'Eddie Lake' },
  { id: 4, header: 'Technical approach', type: 'Narrative', status: 'Done', target: '27', limit: '23', reviewer: 'Jamik Tashpulatov' },
  { id: 5, header: 'Design', type: 'Narrative', status: 'In Process', target: '2', limit: '16', reviewer: 'Jamik Tashpulatov' },
  { id: 6, header: 'Capabilities', type: 'Narrative', status: 'In Process', target: '20', limit: '8', reviewer: 'Jamik Tashpulatov' },
  { id: 7, header: 'Integration with existing systems', type: 'Narrative', status: 'In Process', target: '19', limit: '21', reviewer: 'Jamik Tashpulatov' },
  { id: 8, header: 'Innovation and Advantages', type: 'Narrative', status: 'Done', target: '25', limit: '26', reviewer: 'Assign reviewer' },
  { id: 9, header: 'Overview of EMR\'s Innovative Solutions', type: 'Technical content', status: 'Done', target: '7', limit: '23', reviewer: 'Assign reviewer' },
  { id: 10, header: 'Advanced Algorithms and Machine Learning', type: 'Narrative', status: 'Done', target: '30', limit: '28', reviewer: 'Assign reviewer' },
  { id: 11, header: 'Adaptive Communication Protocols', type: 'Narrative', status: 'Done', target: '9', limit: '31', reviewer: 'Assign reviewer' },
  { id: 12, header: 'Advantages Over Current Technologies', type: 'Narrative', status: 'Done', target: '12', limit: '0', reviewer: 'Assign reviewer' },
  { id: 13, header: 'Past Performance', type: 'Narrative', status: 'Done', target: '22', limit: '33', reviewer: 'Assign reviewer' },
  { id: 14, header: 'Customer Feedback and Satisfaction Levels', type: 'Narrative', status: 'Done', target: '15', limit: '34', reviewer: 'Assign reviewer' },
  { id: 15, header: 'Implementation Challenges and Solutions', type: 'Narrative', status: 'Done', target: '3', limit: '35', reviewer: 'Assign reviewer' },
  { id: 16, header: 'Security Measures and Data Protection Policies', type: 'Narrative', status: 'In Process', target: '6', limit: '36', reviewer: 'Assign reviewer' },
  { id: 17, header: 'Scalability and Future Proofing', type: 'Narrative', status: 'Done', target: '4', limit: '37', reviewer: 'Assign reviewer' },
  { id: 18, header: 'Cost-Benefit Analysis', type: 'Plain language', status: 'Done', target: '14', limit: '38', reviewer: 'Assign reviewer' },
  { id: 19, header: 'User Training and Onboarding Experience', type: 'Narrative', status: 'Done', target: '17', limit: '39', reviewer: 'Assign reviewer' },
  { id: 20, header: 'Future Development Roadmap', type: 'Narrative', status: 'Done', target: '11', limit: '40', reviewer: 'Assign reviewer' },
  { id: 21, header: 'System Architecture Overview', type: 'Technical content', status: 'In Process', target: '24', limit: '18', reviewer: 'Maya Johnson' },
  { id: 22, header: 'Risk Management Plan', type: 'Narrative', status: 'Done', target: '15', limit: '22', reviewer: 'Carlos Rodriguez' },
  { id: 23, header: 'Compliance Documentation', type: 'Legal', status: 'In Process', target: '31', limit: '27', reviewer: 'Sarah Chen' },
  { id: 24, header: 'API Documentation', type: 'Technical content', status: 'Done', target: '8', limit: '12', reviewer: 'Raj Patel' },
  { id: 25, header: 'User Interface Mockups', type: 'Visual', status: 'In Process', target: '19', limit: '25', reviewer: 'Leila Ahmadi' },
  { id: 26, header: 'Database Schema', type: 'Technical content', status: 'Done', target: '22', limit: '20', reviewer: 'Thomas Wilson' },
  { id: 27, header: 'Testing Methodology', type: 'Technical content', status: 'In Process', target: '17', limit: '14', reviewer: 'Assign reviewer' },
  { id: 28, header: 'Deployment Strategy', type: 'Narrative', status: 'Done', target: '26', limit: '30', reviewer: 'Eddie Lake' },
  { id: 29, header: 'Budget Breakdown', type: 'Financial', status: 'In Process', target: '13', limit: '16', reviewer: 'Jamik Tashpulatov' },
  { id: 30, header: 'Market Analysis', type: 'Research', status: 'Done', target: '29', limit: '32', reviewer: 'Sophia Martinez' },
  { id: 31, header: 'Competitor Comparison', type: 'Research', status: 'In Process', target: '21', limit: '19', reviewer: 'Assign reviewer' },
  { id: 32, header: 'Maintenance Plan', type: 'Technical content', status: 'Done', target: '16', limit: '23', reviewer: 'Alex Thompson' },
  { id: 33, header: 'User Personas', type: 'Research', status: 'In Process', target: '27', limit: '24', reviewer: 'Nina Patel' },
  { id: 34, header: 'Accessibility Compliance', type: 'Legal', status: 'Done', target: '18', limit: '21', reviewer: 'Assign reviewer' },
  { id: 35, header: 'Performance Metrics', type: 'Technical content', status: 'In Process', target: '23', limit: '26', reviewer: 'David Kim' },
  { id: 36, header: 'Disaster Recovery Plan', type: 'Technical content', status: 'Done', target: '14', limit: '17', reviewer: 'Jamik Tashpulatov' },
  { id: 37, header: 'Third-party Integrations', type: 'Technical content', status: 'In Process', target: '25', limit: '28', reviewer: 'Eddie Lake' },
  { id: 38, header: 'User Feedback Summary', type: 'Research', status: 'Done', target: '20', limit: '15', reviewer: 'Assign reviewer' },
  { id: 39, header: 'Localization Strategy', type: 'Narrative', status: 'In Process', target: '12', limit: '19', reviewer: 'Maria Garcia' },
  { id: 40, header: 'Mobile Compatibility', type: 'Technical content', status: 'Done', target: '28', limit: '31', reviewer: 'James Wilson' },
  { id: 41, header: 'Data Migration Plan', type: 'Technical content', status: 'In Process', target: '19', limit: '22', reviewer: 'Assign reviewer' },
  { id: 42, header: 'Quality Assurance Protocols', type: 'Technical content', status: 'Done', target: '30', limit: '33', reviewer: 'Priya Singh' },
  { id: 43, header: 'Stakeholder Analysis', type: 'Research', status: 'In Process', target: '11', limit: '14', reviewer: 'Eddie Lake' },
  { id: 44, header: 'Environmental Impact Assessment', type: 'Research', status: 'Done', target: '24', limit: '27', reviewer: 'Assign reviewer' },
  { id: 45, header: 'Intellectual Property Rights', type: 'Legal', status: 'In Process', target: '17', limit: '20', reviewer: 'Sarah Johnson' },
  { id: 46, header: 'Customer Support Framework', type: 'Narrative', status: 'Done', target: '22', limit: '25', reviewer: 'Jamik Tashpulatov' },
  { id: 47, header: 'Version Control Strategy', type: 'Technical content', status: 'In Process', target: '15', limit: '18', reviewer: 'Assign reviewer' },
  { id: 48, header: 'Continuous Integration Pipeline', type: 'Technical content', status: 'Done', target: '26', limit: '29', reviewer: 'Michael Chen' },
  { id: 49, header: 'Regulatory Compliance', type: 'Legal', status: 'In Process', target: '13', limit: '16', reviewer: 'Assign reviewer' },
  { id: 50, header: 'User Authentication System', type: 'Technical content', status: 'Done', target: '28', limit: '31', reviewer: 'Eddie Lake' },
  { id: 51, header: 'Data Analytics Framework', type: 'Technical content', status: 'In Process', target: '21', limit: '24', reviewer: 'Jamik Tashpulatov' },
  { id: 52, header: 'Cloud Infrastructure', type: 'Technical content', status: 'Done', target: '16', limit: '19', reviewer: 'Assign reviewer' },
  { id: 53, header: 'Network Security Measures', type: 'Technical content', status: 'In Process', target: '29', limit: '32', reviewer: 'Lisa Wong' },
  { id: 54, header: 'Project Timeline', type: 'Planning', status: 'Done', target: '14', limit: '17', reviewer: 'Eddie Lake' },
  { id: 55, header: 'Resource Allocation', type: 'Planning', status: 'In Process', target: '27', limit: '30', reviewer: 'Assign reviewer' },
  { id: 56, header: 'Team Structure and Roles', type: 'Planning', status: 'Done', target: '20', limit: '23', reviewer: 'Jamik Tashpulatov' },
  { id: 57, header: 'Communication Protocols', type: 'Planning', status: 'In Process', target: '15', limit: '18', reviewer: 'Assign reviewer' },
  { id: 58, header: 'Success Metrics', type: 'Planning', status: 'Done', target: '30', limit: '33', reviewer: 'Eddie Lake' },
  { id: 59, header: 'Internationalization Support', type: 'Technical content', status: 'In Process', target: '23', limit: '26', reviewer: 'Jamik Tashpulatov' },
  { id: 60, header: 'Backup and Recovery Procedures', type: 'Technical content', status: 'Done', target: '18', limit: '21', reviewer: 'Assign reviewer' },
  { id: 61, header: 'Monitoring and Alerting System', type: 'Technical content', status: 'In Process', target: '25', limit: '28', reviewer: 'Daniel Park' },
  { id: 62, header: 'Code Review Guidelines', type: 'Technical content', status: 'Done', target: '12', limit: '15', reviewer: 'Eddie Lake' },
  { id: 63, header: 'Documentation Standards', type: 'Technical content', status: 'In Process', target: '27', limit: '30', reviewer: 'Jamik Tashpulatov' },
  { id: 64, header: 'Release Management Process', type: 'Planning', status: 'Done', target: '22', limit: '25', reviewer: 'Assign reviewer' },
  { id: 65, header: 'Feature Prioritization Matrix', type: 'Planning', status: 'In Process', target: '19', limit: '22', reviewer: 'Emma Davis' },
  { id: 66, header: 'Technical Debt Assessment', type: 'Technical content', status: 'Done', target: '24', limit: '27', reviewer: 'Eddie Lake' },
  { id: 67, header: 'Capacity Planning', type: 'Planning', status: 'In Process', target: '21', limit: '24', reviewer: 'Jamik Tashpulatov' },
  { id: 68, header: 'Service Level Agreements', type: 'Legal', status: 'Done', target: '26', limit: '29', reviewer: 'Assign reviewer' },
];
```

## Sidebar 07

A sidebar that collapses to icons.

Install it with the CLI, which copies these files into your app:

```bash
npx @webjsdev/ui add sidebar-07
```

Preview: https://webjs.dev/ui/view/sidebar-07

```ts title="app/dashboard/page.ts"
/**
 * The sidebar-07 block's page: a sidebar that collapses to icons, beside a
 * header with a breadcrumb and a placeholder content grid.
 *
 * Installed by `npx @webjsdev/ui add sidebar-07` at `app/dashboard/page.ts`.
 * It is app code you own, so edit it freely. Ported from shadcn/ui's
 * sidebar-07.
 */
import { html } from '@webjsdev/core';
import type { Metadata } from '@webjsdev/core';
import { cn } from '../../lib/utils/cn.ts';
import {
  breadcrumbItemClass,
  breadcrumbLinkClass,
  breadcrumbListClass,
  breadcrumbPageClass,
  breadcrumbSeparatorClass,
} from '../../components/ui/breadcrumb.ts';
import { separatorClass } from '../../components/ui/separator.ts';
import '../../components/ui/sidebar.ts';
import { appSidebar } from '../../components/app-sidebar.ts';
import { ChevronRightIcon } from '../../lib/utils/icons.ts';

export const metadata: Metadata = { title: 'Dashboard' };

export default function DashboardPage() {
  return html`
    <ui-sidebar-provider>
      ${appSidebar()}
      <ui-sidebar-inset>
        <header class="flex h-16 shrink-0 items-center gap-2 transition-[width,height] ease-linear group-has-data-[collapsible=icon]/sidebar-wrapper:h-12">
          <div class="flex items-center gap-2 px-4">
            <ui-sidebar-trigger class="-ml-1"></ui-sidebar-trigger>
            <div role="none" data-slot="separator" data-orientation="vertical" class=${cn(separatorClass(), 'mr-2 data-vertical:h-4 data-vertical:self-auto')}></div>
            <nav aria-label="breadcrumb" data-slot="breadcrumb">
              <ol data-slot="breadcrumb-list" class=${breadcrumbListClass()}>
                <li data-slot="breadcrumb-item" class=${cn(breadcrumbItemClass(), 'hidden md:block')}>
                  <a data-slot="breadcrumb-link" class=${breadcrumbLinkClass()} href="#">Build Your Application</a>
                </li>
                <li data-slot="breadcrumb-separator" role="presentation" aria-hidden="true" class=${cn(breadcrumbSeparatorClass(), 'hidden md:block')}>${ChevronRightIcon()}</li>
                <li data-slot="breadcrumb-item" class=${breadcrumbItemClass()}>
                  <span data-slot="breadcrumb-page" class=${breadcrumbPageClass()} aria-current="page">Data Fetching</span>
                </li>
              </ol>
            </nav>
          </div>
        </header>
        <div class="flex flex-1 flex-col gap-4 p-4 pt-0">
          <div class="grid auto-rows-min gap-4 md:grid-cols-3">
            <div class="aspect-video rounded-xl bg-muted/50"></div>
            <div class="aspect-video rounded-xl bg-muted/50"></div>
            <div class="aspect-video rounded-xl bg-muted/50"></div>
          </div>
          <div class="min-h-screen flex-1 rounded-xl bg-muted/50 md:min-h-min"></div>
        </div>
      </ui-sidebar-inset>
    </ui-sidebar-provider>
  `;
}
```

```ts title="components/app-sidebar.ts"
/**
 * The sidebar-07 app sidebar: a team switcher, the main nav with collapsible
 * sections, the projects list and the signed-in user, in a sidebar that
 * collapses to icons (Ctrl+B or Cmd+B, the trigger, or the rail). A fragment
 * helper, so the markup is rendered by the server; the sidebar, its rail and
 * the menus are the kit's elements. Ported from shadcn/ui's sidebar-07.
 *
 * The data below is sample data. Replace it with your own, and point each
 * `url` at a real route.
 */
import { html } from '@webjsdev/core';
import {
  sidebarContentClass,
  sidebarFooterClass,
  sidebarHeaderClass,
} from './ui/sidebar.ts';
import { navMain, type NavMainItem } from './nav-main.ts';
import { navProjects, type NavProject } from './nav-projects.ts';
import { navUser } from './nav-user.ts';
import { teamSwitcher, type Team } from './team-switcher.ts';
import { AudioLinesIcon, BookOpenIcon, BotIcon, FrameIcon, GalleryVerticalEndIcon, MapIcon, PieChartIcon, Settings2Icon, TerminalIcon, TerminalSquareIcon } from '../lib/utils/icons.ts';

// This is sample data.
const data: {
  user: { name: string; email: string; avatar: string };
  teams: Team[];
  navMain: NavMainItem[];
  projects: NavProject[];
} = {
  user: {
    name: 'vivek',
    email: 'vivek@example.com',
    avatar: 'https://webjs.dev/avatars/vivek.jpg',
  },
  teams: [
    { name: 'Acme Inc', logo: GalleryVerticalEndIcon, plan: 'Enterprise' },
    { name: 'Acme Corp.', logo: AudioLinesIcon, plan: 'Startup' },
    { name: 'Evil Corp.', logo: TerminalIcon, plan: 'Free' },
  ],
  navMain: [
    {
      title: 'Playground',
      url: '#',
      icon: TerminalSquareIcon,
      isActive: true,
      items: [
        { title: 'History', url: '#' },
        { title: 'Starred', url: '#' },
        { title: 'Settings', url: '#' },
      ],
    },
    {
      title: 'Models',
      url: '#',
      icon: BotIcon,
      items: [
        { title: 'Genesis', url: '#' },
        { title: 'Explorer', url: '#' },
        { title: 'Quantum', url: '#' },
      ],
    },
    {
      title: 'Documentation',
      url: '#',
      icon: BookOpenIcon,
      items: [
        { title: 'Introduction', url: '#' },
        { title: 'Get Started', url: '#' },
        { title: 'Tutorials', url: '#' },
        { title: 'Changelog', url: '#' },
      ],
    },
    {
      title: 'Settings',
      url: '#',
      icon: Settings2Icon,
      items: [
        { title: 'General', url: '#' },
        { title: 'Team', url: '#' },
        { title: 'Billing', url: '#' },
        { title: 'Limits', url: '#' },
      ],
    },
  ],
  projects: [
    { name: 'Design Engineering', url: '#', icon: FrameIcon },
    { name: 'Sales & Marketing', url: '#', icon: PieChartIcon },
    { name: 'Travel', url: '#', icon: MapIcon },
  ],
};

export function appSidebar() {
  return html`
    <ui-sidebar collapsible="icon">
      <div data-slot="sidebar-header" data-sidebar="header" class=${sidebarHeaderClass()}>
        ${teamSwitcher({ teams: data.teams })}
      </div>
      <div data-slot="sidebar-content" data-sidebar="content" class=${sidebarContentClass()}>
        ${navMain({ items: data.navMain })}
        ${navProjects({ projects: data.projects })}
      </div>
      <div data-slot="sidebar-footer" data-sidebar="footer" class=${sidebarFooterClass()}>
        ${navUser({ user: data.user })}
      </div>
      <ui-sidebar-rail></ui-sidebar-rail>
    </ui-sidebar>
  `;
}
```

```ts title="components/nav-main.ts"
/**
 * The sidebar-07 main nav: the "Platform" group, each section a collapsible
 * menu item with its pages in a submenu. A fragment helper; each section is a
 * native `<details>`, so it opens and closes with no JavaScript. Ported from
 * shadcn/ui's sidebar-07.
 */
import { html } from '@webjsdev/core';
import type { TemplateResult } from '@webjsdev/core';
import { cn } from '../lib/utils/cn.ts';
import { collapsibleClass, collapsibleContentClass } from './ui/collapsible.ts';
import {
  sidebarGroupClass,
  sidebarGroupLabelClass,
  sidebarMenuButtonClass,
  sidebarMenuClass,
  sidebarMenuItemClass,
  sidebarMenuSubButtonClass,
  sidebarMenuSubClass,
  sidebarMenuSubItemClass,
} from './ui/sidebar.ts';
import { ChevronRightIcon } from '../lib/utils/icons.ts';

export interface NavMainItem {
  title: string;
  url: string;
  icon?: (cls?: string) => TemplateResult;
  isActive?: boolean;
  items?: { title: string; url: string }[];
}

export function navMain({ items }: { items: NavMainItem[] }) {
  return html`
    <div data-slot="sidebar-group" data-sidebar="group" class=${sidebarGroupClass()}>
      <div data-slot="sidebar-group-label" data-sidebar="group-label" class=${sidebarGroupLabelClass()}>Platform</div>
      <ul data-slot="sidebar-menu" data-sidebar="menu" class=${sidebarMenuClass()}>
        ${items.map((item) => html`
          <li data-slot="sidebar-menu-item" data-sidebar="menu-item" class=${sidebarMenuItemClass()}>
            <details data-slot="collapsible" class=${cn(collapsibleClass(), 'group/collapsible')} ?open=${!!item.isActive}>
              <summary data-slot="sidebar-menu-button" data-sidebar="menu-button" data-size="default" class=${cn(sidebarMenuButtonClass(), 'cursor-pointer list-none [&::-webkit-details-marker]:hidden')}>
                ${item.icon ? item.icon() : ''}
                <span>${item.title}</span>
                ${ChevronRightIcon('ml-auto transition-transform duration-200 group-open/collapsible:rotate-90')}
              </summary>
              <div data-slot="collapsible-content" class=${collapsibleContentClass()}>
                <ul data-slot="sidebar-menu-sub" data-sidebar="menu-sub" class=${sidebarMenuSubClass()}>
                  ${(item.items ?? []).map((sub) => html`
                    <li data-slot="sidebar-menu-sub-item" data-sidebar="menu-sub-item" class=${sidebarMenuSubItemClass()}>
                      <a href=${sub.url} data-slot="sidebar-menu-sub-button" data-sidebar="menu-sub-button" data-size="md" class=${sidebarMenuSubButtonClass()}>
                        <span>${sub.title}</span>
                      </a>
                    </li>
                  `)}
                </ul>
              </div>
            </details>
          </li>
        `)}
      </ul>
    </div>
  `;
}
```

```ts title="components/nav-projects.ts"
/**
 * The sidebar-07 projects list: one link per project, each with a "More"
 * menu that shows on hover, and a trailing "More" item. Hidden while the
 * sidebar is collapsed to icons. A fragment helper; the menus are the kit's
 * `<ui-dropdown-menu>`. Ported from shadcn/ui's sidebar-07.
 *
 * Each "More" button sits right after its link, a sibling of it, because the
 * kit's styles place it with `peer-*` selectors that need exactly that. The
 * menu names it through `trigger="<id>"`, so the ids must be unique on the page.
 */
import { html } from '@webjsdev/core';
import type { TemplateResult } from '@webjsdev/core';
import { cn } from '../lib/utils/cn.ts';
import './ui/dropdown-menu.ts';
import {
  sidebarGroupClass,
  sidebarGroupLabelClass,
  sidebarMenuActionClass,
  sidebarMenuButtonClass,
  sidebarMenuClass,
  sidebarMenuItemClass,
} from './ui/sidebar.ts';
import { ArrowRightIcon, FolderIcon, MoreHorizontalIcon, Trash2Icon } from '../lib/utils/icons.ts';

export interface NavProject {
  name: string;
  url: string;
  icon: (cls?: string) => TemplateResult;
}

export function navProjects({ projects }: { projects: NavProject[] }) {
  return html`
    <div data-slot="sidebar-group" data-sidebar="group" class=${cn(sidebarGroupClass(), 'group-data-[collapsible=icon]:hidden')}>
      <div data-slot="sidebar-group-label" data-sidebar="group-label" class=${sidebarGroupLabelClass()}>Projects</div>
      <ul data-slot="sidebar-menu" data-sidebar="menu" class=${sidebarMenuClass()}>
        ${projects.map((item, i) => html`
          <li data-slot="sidebar-menu-item" data-sidebar="menu-item" class=${sidebarMenuItemClass()}>
            <a href=${item.url} data-slot="sidebar-menu-button" data-sidebar="menu-button" data-size="default" class=${sidebarMenuButtonClass()}>
              ${item.icon()}
              <span>${item.name}</span>
            </a>
            <button type="button" id=${`nav-project-more-${i}`} data-slot="sidebar-menu-action" data-sidebar="menu-action" class=${cn(sidebarMenuActionClass({ showOnHover: true }), 'aria-expanded:bg-muted')}>
              ${MoreHorizontalIcon()}
              <span class="sr-only">More</span>
            </button>
            <ui-dropdown-menu trigger=${`nav-project-more-${i}`}>
              <ui-dropdown-menu-content class="w-fit" side="right" align="start">
                <ui-dropdown-menu-item>${FolderIcon()}<span>View Project</span></ui-dropdown-menu-item>
                <ui-dropdown-menu-item>${ArrowRightIcon()}<span>Share Project</span></ui-dropdown-menu-item>
                <ui-dropdown-menu-separator></ui-dropdown-menu-separator>
                <ui-dropdown-menu-item variant="destructive">${Trash2Icon()}<span>Delete Project</span></ui-dropdown-menu-item>
              </ui-dropdown-menu-content>
            </ui-dropdown-menu>
          </li>
        `)}
        <li data-slot="sidebar-menu-item" data-sidebar="menu-item" class=${sidebarMenuItemClass()}>
          <button type="button" data-slot="sidebar-menu-button" data-sidebar="menu-button" data-size="default" class=${cn(sidebarMenuButtonClass(), 'text-sidebar-foreground/70')}>
            ${MoreHorizontalIcon('text-sidebar-foreground/70')}
            <span>More</span>
          </button>
        </li>
      </ul>
    </div>
  `;
}
```

```ts title="components/nav-user.ts"
/**
 * The sidebar-07 user menu: the signed-in user's avatar, name and email,
 * opening an account menu. A fragment helper; the menu is the kit's
 * `<ui-dropdown-menu>`. Ported from shadcn/ui's sidebar-07.
 *
 * The menu items are placeholders. Make "Log out" a form that posts to your
 * sign-out action, and the others links to your account pages.
 */
import { html } from '@webjsdev/core';
import { cn } from '../lib/utils/cn.ts';
import { avatarClass, avatarFallbackClass, avatarImageClass } from './ui/avatar.ts';
import './ui/dropdown-menu.ts';
import {
  sidebarMenuButtonClass,
  sidebarMenuClass,
  sidebarMenuItemClass,
} from './ui/sidebar.ts';
import { BadgeCheckIcon, BellIcon, ChevronsUpDownIcon, CreditCardIcon, LogOutIcon, SparklesIcon } from '../lib/utils/icons.ts';

function userAvatar(user: { name: string; avatar: string }) {
  return html`<span data-slot="avatar" data-size="default" class=${cn(avatarClass(), 'h-8 w-8 rounded-lg')}>
    <span data-slot="avatar-fallback" class=${cn(avatarFallbackClass(), 'rounded-lg')}>VK</span>
    <img data-slot="avatar-image" src=${user.avatar} alt="@vivek" class=${avatarImageClass()}>
  </span>`;
}

function userText(user: { name: string; email: string }) {
  return html`<div class="grid flex-1 text-left text-sm leading-tight">
    <span class="truncate font-medium">${user.name}</span>
    <span class="truncate text-xs">${user.email}</span>
  </div>`;
}

export function navUser({ user }: { user: { name: string; email: string; avatar: string } }) {
  return html`
    <ul data-slot="sidebar-menu" data-sidebar="menu" class=${sidebarMenuClass()}>
      <li data-slot="sidebar-menu-item" data-sidebar="menu-item" class=${sidebarMenuItemClass()}>
        <ui-dropdown-menu>
          <ui-dropdown-menu-trigger>
            <button type="button" data-slot="sidebar-menu-button" data-sidebar="menu-button" data-size="lg" class=${cn(sidebarMenuButtonClass({ size: 'lg' }), 'aria-expanded:bg-sidebar-accent aria-expanded:text-sidebar-accent-foreground')}>
              ${userAvatar(user)}
              ${userText(user)}
              ${ChevronsUpDownIcon('ml-auto size-4')}
            </button>
          </ui-dropdown-menu-trigger>
          <ui-dropdown-menu-content class="w-fit" side="right" align="end">
            <ui-dropdown-menu-label class="p-0 font-normal">
              <div class="flex items-center gap-2 px-1 py-1.5 text-left text-sm">
                ${userAvatar(user)}
                ${userText(user)}
              </div>
            </ui-dropdown-menu-label>
            <ui-dropdown-menu-separator></ui-dropdown-menu-separator>
            <ui-dropdown-menu-group>
              <ui-dropdown-menu-item>${SparklesIcon()}Upgrade to Pro</ui-dropdown-menu-item>
            </ui-dropdown-menu-group>
            <ui-dropdown-menu-separator></ui-dropdown-menu-separator>
            <ui-dropdown-menu-group>
              <ui-dropdown-menu-item>${BadgeCheckIcon()}Account</ui-dropdown-menu-item>
              <ui-dropdown-menu-item>${CreditCardIcon()}Billing</ui-dropdown-menu-item>
              <ui-dropdown-menu-item>${BellIcon()}Notifications</ui-dropdown-menu-item>
            </ui-dropdown-menu-group>
            <ui-dropdown-menu-separator></ui-dropdown-menu-separator>
            <ui-dropdown-menu-item>${LogOutIcon()}Log out</ui-dropdown-menu-item>
          </ui-dropdown-menu-content>
        </ui-dropdown-menu>
      </li>
    </ul>
  `;
}
```

```ts title="components/team-switcher.ts"
/**
 * The sidebar-07 team switcher: the active team's logo, name and plan,
 * opening a menu of the teams. A fragment helper; the menu is the kit's
 * `<ui-dropdown-menu>`. Ported from shadcn/ui's sidebar-07.
 *
 * It renders the first team as the active one. shadcn keeps the choice in
 * React state; in your app the active team is server data (a session value or
 * a route segment), so render the right one on the server and make each item
 * a link or a form that switches it.
 */
import { html } from '@webjsdev/core';
import type { TemplateResult } from '@webjsdev/core';
import { cn } from '../lib/utils/cn.ts';
import './ui/dropdown-menu.ts';
import {
  sidebarMenuButtonClass,
  sidebarMenuClass,
  sidebarMenuItemClass,
} from './ui/sidebar.ts';
import { ChevronsUpDownIcon, PlusIcon } from '../lib/utils/icons.ts';

export interface Team {
  name: string;
  logo: (cls?: string) => TemplateResult;
  plan: string;
}

export function teamSwitcher({ teams }: { teams: Team[] }) {
  const active = teams[0];
  if (!active) return '';
  return html`
    <ul data-slot="sidebar-menu" data-sidebar="menu" class=${sidebarMenuClass()}>
      <li data-slot="sidebar-menu-item" data-sidebar="menu-item" class=${sidebarMenuItemClass()}>
        <ui-dropdown-menu>
          <ui-dropdown-menu-trigger>
            <button type="button" data-slot="sidebar-menu-button" data-sidebar="menu-button" data-size="lg" class=${cn(sidebarMenuButtonClass({ size: 'lg' }), 'aria-expanded:bg-sidebar-accent aria-expanded:text-sidebar-accent-foreground')}>
              <div class="flex aspect-square size-8 items-center justify-center rounded-lg bg-sidebar-primary text-sidebar-primary-foreground">
                ${active.logo()}
              </div>
              <div class="grid flex-1 text-left text-sm leading-tight">
                <span class="truncate font-medium">${active.name}</span>
                <span class="truncate text-xs">${active.plan}</span>
              </div>
              ${ChevronsUpDownIcon('ml-auto')}
            </button>
          </ui-dropdown-menu-trigger>
          <ui-dropdown-menu-content class="w-fit" side="right" align="start">
            <ui-dropdown-menu-label class="text-xs text-muted-foreground">Teams</ui-dropdown-menu-label>
            ${teams.map((team, index) => html`
              <ui-dropdown-menu-item class="gap-2 p-2">
                <div class="flex size-6 items-center justify-center rounded-md border">${team.logo()}</div>
                ${team.name}
                <ui-dropdown-menu-shortcut>⌘${index + 1}</ui-dropdown-menu-shortcut>
              </ui-dropdown-menu-item>
            `)}
            <ui-dropdown-menu-separator></ui-dropdown-menu-separator>
            <ui-dropdown-menu-item class="gap-2 p-2">
              <div class="flex size-6 items-center justify-center rounded-md border bg-transparent">${PlusIcon('size-4')}</div>
              <div class="font-medium text-muted-foreground">Add team</div>
            </ui-dropdown-menu-item>
          </ui-dropdown-menu-content>
        </ui-dropdown-menu>
      </li>
    </ul>
  `;
}
```

## Sidebar 03

A sidebar with submenus.

Install it with the CLI, which copies these files into your app:

```bash
npx @webjsdev/ui add sidebar-03
```

Preview: https://webjs.dev/ui/view/sidebar-03

```ts title="app/dashboard/page.ts"
/**
 * The sidebar-03 block's page: a docs-style sidebar with each section's
 * pages in a submenu, beside a header with a breadcrumb and a placeholder
 * content grid.
 *
 * Installed by `npx @webjsdev/ui add sidebar-03` at `app/dashboard/page.ts`.
 * It is app code you own, so edit it freely. Ported from shadcn/ui's
 * sidebar-03.
 */
import { html } from '@webjsdev/core';
import type { Metadata } from '@webjsdev/core';
import { cn } from '../../lib/utils/cn.ts';
import {
  breadcrumbItemClass,
  breadcrumbLinkClass,
  breadcrumbListClass,
  breadcrumbPageClass,
  breadcrumbSeparatorClass,
} from '../../components/ui/breadcrumb.ts';
import { separatorClass } from '../../components/ui/separator.ts';
import '../../components/ui/sidebar.ts';
import { appSidebar } from '../../components/app-sidebar.ts';
import { ChevronRightIcon } from '../../lib/utils/icons.ts';

export const metadata: Metadata = { title: 'Dashboard' };

export default function DashboardPage() {
  return html`
    <ui-sidebar-provider>
      ${appSidebar()}
      <ui-sidebar-inset>
        <header class="flex h-16 shrink-0 items-center gap-2 border-b">
          <div class="flex items-center gap-2 px-3">
            <ui-sidebar-trigger></ui-sidebar-trigger>
            <div role="none" data-slot="separator" data-orientation="vertical" class=${cn(separatorClass(), 'mr-2 data-vertical:h-4 data-vertical:self-auto')}></div>
            <nav aria-label="breadcrumb" data-slot="breadcrumb">
              <ol data-slot="breadcrumb-list" class=${breadcrumbListClass()}>
                <li data-slot="breadcrumb-item" class=${cn(breadcrumbItemClass(), 'hidden md:block')}>
                  <a data-slot="breadcrumb-link" class=${breadcrumbLinkClass()} href="#">Build Your Application</a>
                </li>
                <li data-slot="breadcrumb-separator" role="presentation" aria-hidden="true" class=${cn(breadcrumbSeparatorClass(), 'hidden md:block')}>${ChevronRightIcon()}</li>
                <li data-slot="breadcrumb-item" class=${breadcrumbItemClass()}>
                  <span data-slot="breadcrumb-page" class=${breadcrumbPageClass()} aria-current="page">Data Fetching</span>
                </li>
              </ol>
            </nav>
          </div>
        </header>
        <div class="flex flex-1 flex-col gap-4 p-4">
          <div class="grid auto-rows-min gap-4 md:grid-cols-3">
            <div class="aspect-video rounded-xl bg-muted/50"></div>
            <div class="aspect-video rounded-xl bg-muted/50"></div>
            <div class="aspect-video rounded-xl bg-muted/50"></div>
          </div>
          <div class="min-h-screen flex-1 rounded-xl bg-muted/50 md:min-h-min"></div>
        </div>
      </ui-sidebar-inset>
    </ui-sidebar-provider>
  `;
}
```

```ts title="components/app-sidebar.ts"
/**
 * The sidebar-03 app sidebar: the docs logo and version in the header, then
 * each docs section as a menu item with its pages in a submenu. A fragment
 * helper, so the markup is rendered by the server; the sidebar and its rail
 * are the kit's elements. Ported from shadcn/ui's sidebar-03.
 *
 * The data below is sample data. Replace it with your own, point each `url`
 * at a real route, and mark the current page with `isActive`.
 */
import { html, nothing } from '@webjsdev/core';
import { cn } from '../lib/utils/cn.ts';
import {
  sidebarContentClass,
  sidebarGroupClass,
  sidebarHeaderClass,
  sidebarMenuButtonClass,
  sidebarMenuClass,
  sidebarMenuItemClass,
  sidebarMenuSubButtonClass,
  sidebarMenuSubClass,
  sidebarMenuSubItemClass,
} from './ui/sidebar.ts';
import { GalleryVerticalEndIcon } from '../lib/utils/icons.ts';

interface NavSection {
  title: string;
  url: string;
  items: { title: string; url: string; isActive?: boolean }[];
}

// This is sample data.
const data: { navMain: NavSection[] } = {
  navMain: [
    {
      title: 'Getting Started',
      url: '#',
      items: [
        { title: 'Installation', url: '#' },
        { title: 'Project Structure', url: '#' },
      ],
    },
    {
      title: 'Build Your Application',
      url: '#',
      items: [
        { title: 'Routing', url: '#' },
        { title: 'Data Fetching', url: '#', isActive: true },
        { title: 'Rendering', url: '#' },
        { title: 'Caching', url: '#' },
        { title: 'Styling', url: '#' },
        { title: 'Optimizing', url: '#' },
        { title: 'Configuring', url: '#' },
        { title: 'Testing', url: '#' },
        { title: 'Authentication', url: '#' },
        { title: 'Deploying', url: '#' },
        { title: 'Upgrading', url: '#' },
        { title: 'Examples', url: '#' },
      ],
    },
    {
      title: 'API Reference',
      url: '#',
      items: [
        { title: 'Components', url: '#' },
        { title: 'File Conventions', url: '#' },
        { title: 'Functions', url: '#' },
        { title: 'next.config.js Options', url: '#' },
        { title: 'CLI', url: '#' },
        { title: 'Edge Runtime', url: '#' },
      ],
    },
    {
      title: 'Architecture',
      url: '#',
      items: [
        { title: 'Accessibility', url: '#' },
        { title: 'Fast Refresh', url: '#' },
        { title: 'Next.js Compiler', url: '#' },
        { title: 'Supported Browsers', url: '#' },
        { title: 'Turbopack', url: '#' },
      ],
    },
    {
      title: 'Community',
      url: '#',
      items: [
        { title: 'Contribution Guide', url: '#' },
      ],
    },
  ],
};

export function appSidebar() {
  return html`
    <ui-sidebar>
      <div data-slot="sidebar-header" data-sidebar="header" class=${sidebarHeaderClass()}>
        <ul data-slot="sidebar-menu" data-sidebar="menu" class=${sidebarMenuClass()}>
          <li data-slot="sidebar-menu-item" data-sidebar="menu-item" class=${sidebarMenuItemClass()}>
            <a href="#" data-slot="sidebar-menu-button" data-sidebar="menu-button" data-size="lg" class=${sidebarMenuButtonClass({ size: 'lg' })}>
              <div class="flex aspect-square size-8 items-center justify-center rounded-lg bg-sidebar-primary text-sidebar-primary-foreground">
                ${GalleryVerticalEndIcon('size-4')}
              </div>
              <div class="flex flex-col gap-0.5 leading-none">
                <span class="font-medium">Documentation</span>
                <span>v1.0.0</span>
              </div>
            </a>
          </li>
        </ul>
      </div>
      <nav aria-label="Docs" data-slot="sidebar-content" data-sidebar="content" class=${sidebarContentClass()}>
        <div data-slot="sidebar-group" data-sidebar="group" class=${sidebarGroupClass()}>
          <ul data-slot="sidebar-menu" data-sidebar="menu" class=${sidebarMenuClass()}>
            ${data.navMain.map((section) => html`
              <li data-slot="sidebar-menu-item" data-sidebar="menu-item" class=${sidebarMenuItemClass()}>
                <a href=${section.url} data-slot="sidebar-menu-button" data-sidebar="menu-button" data-size="default" class=${cn(sidebarMenuButtonClass(), 'font-medium')}>${section.title}</a>
                ${section.items.length ? html`
                  <ul data-slot="sidebar-menu-sub" data-sidebar="menu-sub" class=${sidebarMenuSubClass()}>
                    ${section.items.map((item) => html`
                      <li data-slot="sidebar-menu-sub-item" data-sidebar="menu-sub-item" class=${sidebarMenuSubItemClass()}>
                        <a href=${item.url} data-slot="sidebar-menu-sub-button" data-sidebar="menu-sub-button" data-size="md" data-active=${item.isActive ? 'true' : 'false'} aria-current=${item.isActive ? 'page' : nothing} class=${sidebarMenuSubButtonClass()}>${item.title}</a>
                      </li>
                    `)}
                  </ul>
                ` : ''}
              </li>
            `)}
          </ul>
        </div>
      </nav>
      <ui-sidebar-rail></ui-sidebar-rail>
    </ui-sidebar>
  `;
}
```

## Login 03

A login page with a muted background color.

Install it with the CLI, which copies these files into your app:

```bash
npx @webjsdev/ui add login-03
```

Preview: https://webjs.dev/ui/view/login-03

```ts title="app/login/page.ts"
/**
 * The login-03 block's page: the brand above a login card, on a muted
 * background.
 *
 * Installed by `npx @webjsdev/ui add login-03` at `app/login/page.ts`.
 * Ported from shadcn/ui's login-03.
 */
import { html } from '@webjsdev/core';
import type { Metadata } from '@webjsdev/core';
import { loginForm } from '../../components/login-form.ts';

export const metadata: Metadata = { title: 'Login' };

export default function LoginPage() {
  return html`
    <div class="flex min-h-svh flex-col items-center justify-center gap-6 bg-muted p-6 md:p-10">
      <div class="flex w-full max-w-sm flex-col gap-6">
        <a href="/" class="flex items-center gap-2 self-center font-medium">
          <div class="flex size-6 items-center justify-center rounded-md bg-primary text-primary-foreground">
            <svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="size-4" aria-hidden="true"><path d="M7 2h10"></path><path d="M5 6h14"></path><rect width="18" height="12" x="3" y="10" rx="2"></rect></svg>
          </div>
          Acme Inc.
        </a>
        ${loginForm()}
      </div>
    </div>
  `;
}
```

```ts title="components/login-form.ts"
/**
 * The login-03 form: a centred "Welcome back" card with Apple and Google
 * buttons above an email and password form, and the terms line under the
 * card. A fragment helper (a function returning an `html` template), so it
 * renders on the server and ships no JavaScript. Ported from shadcn/ui's
 * login-03.
 *
 * The `<form>` has no `action` yet. Bind a server action from a
 * `'use server'` file (`<form action=${signIn}>`) before you ship it: the
 * framework then supplies `method="post"`, and the no-JS post, the 422
 * re-render with `fieldErrors` / `values`, and the 303 redirect all work.
 * Until it is bound, the form submits as a GET back to the page with the
 * typed values in the URL. The provider buttons are placeholders for your
 * providers' sign-in links.
 */
import { html } from '@webjsdev/core';
import { cn } from '../lib/utils/cn.ts';
import { buttonClass } from './ui/button.ts';
import {
  cardClass,
  cardContentClass,
  cardDescriptionClass,
  cardHeaderClass,
  cardTitleClass,
} from './ui/card.ts';
import {
  fieldClass,
  fieldDescriptionClass,
  fieldGroupClass,
  fieldLabelClass,
  fieldSeparatorClass,
  fieldSeparatorContentClass,
} from './ui/field.ts';
import { inputClass } from './ui/input.ts';

const APPLE = 'M12.152 6.896c-.948 0-2.415-1.078-3.96-1.04-2.04.027-3.91 1.183-4.961 3.014-2.117 3.675-.546 9.103 1.519 12.09 1.013 1.454 2.208 3.09 3.792 3.039 1.52-.065 2.09-.987 3.935-.987 1.831 0 2.35.987 3.96.948 1.637-.026 2.676-1.48 3.676-2.948 1.156-1.688 1.636-3.325 1.662-3.415-.039-.013-3.182-1.221-3.22-4.857-.026-3.04 2.48-4.494 2.597-4.559-1.429-2.09-3.623-2.324-4.39-2.376-2-.156-3.675 1.09-4.61 1.09zM15.53 3.83c.843-1.012 1.4-2.427 1.245-3.83-1.207.052-2.662.805-3.532 1.818-.78.896-1.454 2.338-1.273 3.714 1.338.104 2.715-.688 3.559-1.701';
const GOOGLE = 'M12.48 10.92v3.28h7.84c-.24 1.84-.853 3.187-1.787 4.133-1.147 1.147-2.933 2.4-6.053 2.4-4.827 0-8.6-3.893-8.6-8.72s3.773-8.72 8.6-8.72c2.6 0 4.507 1.027 5.907 2.347l2.307-2.307C18.747 1.44 16.133 0 12.48 0 5.867 0 .307 5.387.307 12s5.56 12 12.173 12c3.573 0 6.267-1.173 8.373-3.36 2.16-2.16 2.84-5.213 2.84-7.667 0-.76-.053-1.467-.173-2.053H12.48z';

export function loginForm(opts: { class?: string } = {}) {
  return html`
    <div class=${cn('flex flex-col gap-6', opts.class)}>
      <div class=${cardClass()} data-slot="card" data-size="default">
        <div class=${cn(cardHeaderClass(), 'text-center')} data-slot="card-header">
          <h1 class=${cn(cardTitleClass(), 'text-xl')} data-slot="card-title">Welcome back</h1>
          <p class=${cardDescriptionClass()} data-slot="card-description">Login with your Apple or Google account</p>
        </div>
        <div class=${cardContentClass()} data-slot="card-content">
          <form>
            <div class=${fieldGroupClass()} data-slot="field-group">
              <div class=${fieldClass()} data-slot="field" data-orientation="vertical">
                <button class=${buttonClass({ variant: 'outline' })} data-slot="button" type="button">
                  <svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" aria-hidden="true"><path d=${APPLE} fill="currentColor"></path></svg>
                  Login with Apple
                </button>
                <button class=${buttonClass({ variant: 'outline' })} data-slot="button" type="button">
                  <svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" aria-hidden="true"><path d=${GOOGLE} fill="currentColor"></path></svg>
                  Login with Google
                </button>
              </div>
              <div class=${cn(fieldSeparatorClass(), '*:data-[slot=field-separator-content]:bg-card')} data-slot="field-separator" role="none">
                <span class=${fieldSeparatorContentClass()} data-slot="field-separator-content">Or continue with</span>
              </div>
              <div class=${fieldClass()} data-slot="field" data-orientation="vertical">
                <label class=${fieldLabelClass()} data-slot="field-label" for="email">Email</label>
                <input class=${inputClass()} data-slot="input" id="email" name="email" type="email" autocomplete="email" placeholder="m@example.com" required>
              </div>
              <div class=${fieldClass()} data-slot="field" data-orientation="vertical">
                <div class="flex items-center">
                  <label class=${fieldLabelClass()} data-slot="field-label" for="password">Password</label>
                  <a href="#" class="ml-auto text-sm underline-offset-4 hover:underline">Forgot your password?</a>
                </div>
                <input class=${inputClass()} data-slot="input" id="password" name="password" type="password" autocomplete="current-password" required>
              </div>
              <div class=${fieldClass()} data-slot="field" data-orientation="vertical">
                <button class=${buttonClass()} data-slot="button" type="submit">Login</button>
                <p class=${cn(fieldDescriptionClass(), 'text-center')} data-slot="field-description">
                  Don't have an account? <a href="/signup">Sign up</a>
                </p>
              </div>
            </div>
          </form>
        </div>
      </div>
      <p class=${cn(fieldDescriptionClass(), 'px-6 text-center')} data-slot="field-description">
        By clicking continue, you agree to our <a href="#">Terms of Service</a> and <a href="#">Privacy Policy</a>.
      </p>
    </div>
  `;
}
```

## Login 04

A login page with form and image.

Install it with the CLI, which copies these files into your app:

```bash
npx @webjsdev/ui add login-04
```

Preview: https://webjs.dev/ui/view/login-04

```ts title="app/login/page.ts"
/**
 * The login-04 block's page: a wide login card with the form beside an
 * image, on a muted background.
 *
 * Installed by `npx @webjsdev/ui add login-04` at `app/login/page.ts`, with
 * the image at `public/placeholder.svg`. Ported from shadcn/ui's login-04.
 */
import { html } from '@webjsdev/core';
import type { Metadata } from '@webjsdev/core';
import { loginForm } from '../../components/login-form.ts';

export const metadata: Metadata = { title: 'Login' };

export default function LoginPage() {
  return html`
    <div class="flex min-h-svh flex-col items-center justify-center bg-muted p-6 md:p-10">
      <div class="w-full max-w-sm md:max-w-4xl">${loginForm()}</div>
    </div>
  `;
}
```

```ts title="components/login-form.ts"
/**
 * The login-04 form: a two column card, the email and password form with
 * icon-only Apple, Google and Meta buttons on one side and an image on the
 * other (hidden below `md`), and the terms line under the card. A fragment
 * helper (a function returning an `html` template), so it renders on the
 * server and ships no JavaScript. Ported from shadcn/ui's login-04.
 *
 * The `<form>` has no `action` yet. Bind a server action from a
 * `'use server'` file (`<form action=${signIn}>`) before you ship it: the
 * framework then supplies `method="post"`, and the no-JS post, the 422
 * re-render with `fieldErrors` / `values`, and the 303 redirect all work.
 * Until it is bound, the form submits as a GET back to the page with the
 * typed values in the URL. The provider buttons are placeholders for your
 * providers' sign-in links.
 */
import { html } from '@webjsdev/core';
import { cn } from '../lib/utils/cn.ts';
import { buttonClass } from './ui/button.ts';
import { cardClass, cardContentClass } from './ui/card.ts';
import {
  fieldClass,
  fieldDescriptionClass,
  fieldGroupClass,
  fieldLabelClass,
  fieldSeparatorClass,
  fieldSeparatorContentClass,
} from './ui/field.ts';
import { inputClass } from './ui/input.ts';

const APPLE = 'M12.152 6.896c-.948 0-2.415-1.078-3.96-1.04-2.04.027-3.91 1.183-4.961 3.014-2.117 3.675-.546 9.103 1.519 12.09 1.013 1.454 2.208 3.09 3.792 3.039 1.52-.065 2.09-.987 3.935-.987 1.831 0 2.35.987 3.96.948 1.637-.026 2.676-1.48 3.676-2.948 1.156-1.688 1.636-3.325 1.662-3.415-.039-.013-3.182-1.221-3.22-4.857-.026-3.04 2.48-4.494 2.597-4.559-1.429-2.09-3.623-2.324-4.39-2.376-2-.156-3.675 1.09-4.61 1.09zM15.53 3.83c.843-1.012 1.4-2.427 1.245-3.83-1.207.052-2.662.805-3.532 1.818-.78.896-1.454 2.338-1.273 3.714 1.338.104 2.715-.688 3.559-1.701';
const GOOGLE = 'M12.48 10.92v3.28h7.84c-.24 1.84-.853 3.187-1.787 4.133-1.147 1.147-2.933 2.4-6.053 2.4-4.827 0-8.6-3.893-8.6-8.72s3.773-8.72 8.6-8.72c2.6 0 4.507 1.027 5.907 2.347l2.307-2.307C18.747 1.44 16.133 0 12.48 0 5.867 0 .307 5.387.307 12s5.56 12 12.173 12c3.573 0 6.267-1.173 8.373-3.36 2.16-2.16 2.84-5.213 2.84-7.667 0-.76-.053-1.467-.173-2.053H12.48z';
const META = 'M6.915 4.03c-1.968 0-3.683 1.28-4.871 3.113C.704 9.208 0 11.883 0 14.449c0 .706.07 1.369.21 1.973a6.624 6.624 0 0 0 .265.86 5.297 5.297 0 0 0 .371.761c.696 1.159 1.818 1.927 3.593 1.927 1.497 0 2.633-.671 3.965-2.444.76-1.012 1.144-1.626 2.663-4.32l.756-1.339.186-.325c.061.1.121.196.183.3l2.152 3.595c.724 1.21 1.665 2.556 2.47 3.314 1.046.987 1.992 1.22 3.06 1.22 1.075 0 1.876-.355 2.455-.843a3.743 3.743 0 0 0 .81-.973c.542-.939.861-2.127.861-3.745 0-2.72-.681-5.357-2.084-7.45-1.282-1.912-2.957-2.93-4.716-2.93-1.047 0-2.088.467-3.053 1.308-.652.57-1.257 1.29-1.82 2.05-.69-.875-1.335-1.547-1.958-2.056-1.182-.966-2.315-1.303-3.454-1.303zm10.16 2.053c1.147 0 2.188.758 2.992 1.999 1.132 1.748 1.647 4.195 1.647 6.4 0 1.548-.368 2.9-1.839 2.9-.58 0-1.027-.23-1.664-1.004-.496-.601-1.343-1.878-2.832-4.358l-.617-1.028a44.908 44.908 0 0 0-1.255-1.98c.07-.109.141-.224.211-.327 1.12-1.667 2.118-2.602 3.358-2.602zm-10.201.553c1.265 0 2.058.791 2.675 1.446.307.327.737.871 1.234 1.579l-1.02 1.566c-.757 1.163-1.882 3.017-2.837 4.338-1.191 1.649-1.81 1.817-2.486 1.817-.524 0-1.038-.237-1.383-.794-.263-.426-.464-1.13-.464-2.046 0-2.221.63-4.535 1.66-6.088.454-.687.964-1.226 1.533-1.533a2.264 2.264 0 0 1 1.088-.285z';

export function loginForm(opts: { class?: string } = {}) {
  return html`
    <div class=${cn('flex flex-col gap-6', opts.class)}>
      <div class=${cn(cardClass(), 'overflow-hidden p-0')} data-slot="card" data-size="default">
        <div class=${cn(cardContentClass(), 'grid p-0 md:grid-cols-2')} data-slot="card-content">
          <form class="p-6 md:p-8">
            <div class=${fieldGroupClass()} data-slot="field-group">
              <div class="flex flex-col items-center gap-2 text-center">
                <h1 class="text-2xl font-bold">Welcome back</h1>
                <p class="text-balance text-muted-foreground">Login to your Acme Inc account</p>
              </div>
              <div class=${fieldClass()} data-slot="field" data-orientation="vertical">
                <label class=${fieldLabelClass()} data-slot="field-label" for="email">Email</label>
                <input class=${inputClass()} data-slot="input" id="email" name="email" type="email" autocomplete="email" placeholder="m@example.com" required>
              </div>
              <div class=${fieldClass()} data-slot="field" data-orientation="vertical">
                <div class="flex items-center">
                  <label class=${fieldLabelClass()} data-slot="field-label" for="password">Password</label>
                  <a href="#" class="ml-auto text-sm underline-offset-2 hover:underline">Forgot your password?</a>
                </div>
                <input class=${inputClass()} data-slot="input" id="password" name="password" type="password" autocomplete="current-password" required>
              </div>
              <div class=${fieldClass()} data-slot="field" data-orientation="vertical">
                <button class=${buttonClass()} data-slot="button" type="submit">Login</button>
              </div>
              <div class=${cn(fieldSeparatorClass(), '*:data-[slot=field-separator-content]:bg-card')} data-slot="field-separator" role="none">
                <span class=${fieldSeparatorContentClass()} data-slot="field-separator-content">Or continue with</span>
              </div>
              <div class=${cn(fieldClass(), 'grid grid-cols-3 gap-4')} data-slot="field" data-orientation="vertical">
                <button class=${buttonClass({ variant: 'outline' })} data-slot="button" type="button">
                  <svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" aria-hidden="true"><path d=${APPLE} fill="currentColor"></path></svg>
                  <span class="sr-only">Login with Apple</span>
                </button>
                <button class=${buttonClass({ variant: 'outline' })} data-slot="button" type="button">
                  <svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" aria-hidden="true"><path d=${GOOGLE} fill="currentColor"></path></svg>
                  <span class="sr-only">Login with Google</span>
                </button>
                <button class=${buttonClass({ variant: 'outline' })} data-slot="button" type="button">
                  <svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" aria-hidden="true"><path d=${META} fill="currentColor"></path></svg>
                  <span class="sr-only">Login with Meta</span>
                </button>
              </div>
              <p class=${cn(fieldDescriptionClass(), 'text-center')} data-slot="field-description">
                Don't have an account? <a href="/signup">Sign up</a>
              </p>
            </div>
          </form>
          <div class="relative hidden bg-muted md:block">
            <img src="/placeholder.svg" alt="" class="absolute inset-0 h-full w-full object-cover dark:brightness-[0.2] dark:grayscale">
          </div>
        </div>
      </div>
      <p class=${cn(fieldDescriptionClass(), 'px-6 text-center')} data-slot="field-description">
        By clicking continue, you agree to our <a href="#">Terms of Service</a> and <a href="#">Privacy Policy</a>.
      </p>
    </div>
  `;
}
```

[Browse more blocks](https://webjs.dev/ui/blocks/sidebar)
