{
  "$schema": "https://ui.shadcn.com/schema/registry-item.json",
  "name": "toolbar",
  "type": "registry:ui",
  "title": "Toolbar",
  "description": "A row of controls that acts as ONE stop in the Tab order: Tab enters the toolbar on its last-focused control and leaves it on the next Tab, and the arrow keys move between the controls inside, Home and End jump to the ends, and focus wraps. A formatting…",
  "author": "ofri-peretz <https://github.com/ofri-peretz>",
  "categories": [
    "form",
    "primitive"
  ],
  "dependencies": [
    "@base-ui/react",
    "class-variance-authority"
  ],
  "registryDependencies": [
    "https://ds.interlace.tools/r/interlace-base.json",
    "https://ds.interlace.tools/r/cn.json"
  ],
  "files": [
    {
      "path": "registry/interlace-ui/toolbar.tsx",
      "target": "components/ui/toolbar.tsx",
      "type": "registry:ui",
      "content": "'use client';\n\nimport * as React from 'react';\n\n// @interlace/toolbar v3.6.1 — Interlace design system.\n// Docs, props and live preview: https://ds.interlace.tools/c/toolbar\n// What changed since: https://ds.interlace.tools/c/toolbar#history\n// Generated banner — keep it, the upgrade diff reads this version.\n\n// Built on Base UI's Toolbar. shadcn has no toolbar; the part names follow\n// Base UI's (Toolbar, ToolbarButton, ToolbarLink, ToolbarGroup,\n// ToolbarSeparator, ToolbarInput).\n// Upstream: https://base-ui.com/react/components/toolbar\n\n/**\n * @interlace/ui — Toolbar\n *\n * A row of controls that acts as ONE stop in the Tab order: Tab enters the\n * toolbar on its last-focused control and leaves it on the next Tab, and the\n * arrow keys move between the controls inside, Home and End jump to the ends,\n * and focus wraps. A formatting bar, a table's bulk actions, a player's\n * transport. Without it, a ten-button bar costs a keyboard user ten Tabs to\n * get past.\n *\n * Base UI owns the roving focus (the arrows; this file adds Home and End),\n * the orientation, and keeping a disabled\n * button focusable (so it can still be found and its tooltip read). We own\n * the surface, and the buttons take Button's own variants and sizes, so a\n * toolbar button is a Button that knows it lives in a toolbar.\n *\n * Any Base UI trigger joins the roving focus through `render`:\n * `<ToolbarButton render={<Toggle />} />`, `<ToolbarButton render={<MenuTrigger />} />`,\n * and a Tooltip wraps the other way round,\n * `<TooltipTrigger render={<ToolbarButton />} />`.\n *\n * ## Anatomy\n *\n *   Toolbar                          (Toolbar.Root — div role=\"toolbar\", data-orientation)\n *     ├─ ToolbarButton               (Toolbar.Button — buttonVariants, ghost / icon-sm by default)\n *     ├─ ToolbarLink                 (Toolbar.Link — an anchor in the same roving order)\n *     ├─ ToolbarSeparator            (Toolbar.Separator — perpendicular to the toolbar)\n *     ├─ ToolbarGroup                (Toolbar.Group — role=\"group\", name it with aria-label)\n *     └─ ToolbarInput                (Toolbar.Input — at most one, and last, in a horizontal bar)\n *\n * The one input goes last because Left and Right move the caret inside it,\n * so they cannot also move between controls; Base UI only lets the arrows out\n * at the ends of the text.\n *\n * ## MIN_VIEWPORT — 320\n *\n * The root wraps (`flex-wrap`), so a long bar breaks onto a second row at the\n * 320 floor instead of overflowing. Roving order follows the DOM, not the\n * rows, which is what a reader of the source order expects.\n *\n * | Rule | Concept                          | Where in this file                                          |\n * | ---- | -------------------------------- | ----------------------------------------------------------- |\n * | R4   | Extends Base UI part props       | `React.ComponentProps<typeof BaseToolbar.*>`                |\n * | R6   | data-slot per part               | toolbar / -button / -link / -group / -separator / -input    |\n * | R7   | cn + ...rest                     | `cn(…, className)` + `{...props}`                           |\n * | R8   | Enums, no booleans               | `orientation`; Button's `variant` and `size`                |\n * | R12  | Reuse over wrap                  | Base UI owns roving focus; Button owns the button look      |\n * | R14  | Declares min viewport            | `data-min-viewport` + exported const                        |\n * | R19  | Tokens only                      | `bg-border`, `border-input`, `ring-ring/60`; the link inherits its colour |\n * | R25  | Client component                 | Required — Base UI Toolbar ships client hooks               |\n * | R26  | Keyboard contract                | arrows, Home / End, one Tab stop: asserted by `Toolbar.stories.tsx`, locked by `overlay-nav-keyboard-lock` |\n */\n\nimport { Toolbar as BaseToolbar } from '@base-ui/react/toolbar';\nimport type { VariantProps } from 'class-variance-authority';\n\nimport { cn } from '@/lib/utils';\nimport { buttonVariants } from '@/components/ui/button-variants';\n\n/**\n * Minimum viable viewport (CSS px) — DESIGN_PRINCIPLES #14. The root wraps,\n * so nothing overflows at the 320 floor.\n */\nexport const MIN_VIEWPORT = 320 as const;\n\n/**\n * Home and End: the WAI-ARIA toolbar pattern's jump to the first and last\n * control. Base UI's toolbar roves with the arrows only, so the root adds the\n * two keys over the same items, the ones Base UI gave a `tabindex`. Inside the\n * input they stay with the caret.\n */\nfunction jumpToEnd(event: React.KeyboardEvent<HTMLDivElement>) {\n  if (event.key !== 'Home' && event.key !== 'End') return;\n  if (event.altKey || event.ctrlKey || event.metaKey || event.shiftKey) return;\n  if (event.target instanceof HTMLInputElement) return;\n  const items = Array.from(\n    // Any `tabindex`, -1 included: the roving model gives every item one.\n    event.currentTarget.querySelectorAll<HTMLElement>(':is(button, a, input)[tabindex]'),\n  );\n  const target = event.key === 'Home' ? items[0] : items[items.length - 1];\n  if (!target) return;\n  event.preventDefault();\n  target.focus();\n}\n\nfunction Toolbar({\n  className,\n  onKeyDown,\n  ...props\n}: React.ComponentProps<typeof BaseToolbar.Root>) {\n  return (\n    <BaseToolbar.Root\n      data-slot=\"toolbar\"\n      data-min-viewport={String(MIN_VIEWPORT)}\n      onKeyDown={(event) => {\n        // A disabled-but-focusable button already prevented every key but\n        // Tab, so only a prevent added by the caller's handler opts out.\n        const prevented = event.defaultPrevented;\n        onKeyDown?.(event);\n        if (event.defaultPrevented && !prevented) return;\n        jumpToEnd(event);\n      }}\n      className={cn(\n        'group/toolbar flex flex-wrap items-center gap-1',\n        'data-[orientation=vertical]:flex-col data-[orientation=vertical]:flex-nowrap data-[orientation=vertical]:items-stretch',\n        className,\n      )}\n      {...props}\n    />\n  );\n}\n\ntype ToolbarButtonProps = React.ComponentProps<typeof BaseToolbar.Button> &\n  VariantProps<typeof buttonVariants>;\n\nfunction ToolbarButton({ className, variant = 'ghost', size = 'icon-sm', ...props }: ToolbarButtonProps) {\n  return (\n    <BaseToolbar.Button\n      data-slot=\"toolbar-button\"\n      // A disabled toolbar button stays focusable (Base UI's default): it gets\n      // `aria-disabled` and `data-disabled`, not `disabled`, so it dims without\n      // `pointer-events-none` and hovering it can still show why.\n      className={cn(\n        buttonVariants({ variant, size }),\n        // An icon button is a square with no padding. Said outright so a\n        // rendered Toggle's own `px-*` cannot squeeze the icon.\n        size?.startsWith('icon') && 'p-0',\n        'data-[disabled]:pointer-events-auto data-[disabled]:cursor-not-allowed data-[disabled]:opacity-50',\n        className,\n      )}\n      {...props}\n    />\n  );\n}\n\nfunction ToolbarLink({ className, ...props }: React.ComponentProps<typeof BaseToolbar.Link>) {\n  return (\n    <BaseToolbar.Link\n      data-slot=\"toolbar-link\"\n      className={cn(\n        // Inherits its colour and is underlined at rest, like Button's\n        // `link` variant: a toolbar sits on surfaces the DS does not paint.\n        'rounded-md px-2 py-1 text-sm underline decoration-from-font underline-offset-4 focus-visible:outline-hidden hover:decoration-2',\n        'focus-visible:ring-ring focus-visible:ring-2 focus-visible:ring-offset-2 focus-visible:ring-offset-background',\n        className,\n      )}\n      {...props}\n    />\n  );\n}\n\nfunction ToolbarGroup({ className, ...props }: React.ComponentProps<typeof BaseToolbar.Group>) {\n  return (\n    <BaseToolbar.Group\n      data-slot=\"toolbar-group\"\n      className={cn(\n        'flex items-center gap-1',\n        'group-data-[orientation=vertical]/toolbar:flex-col',\n        className,\n      )}\n      {...props}\n    />\n  );\n}\n\nfunction ToolbarSeparator({\n  className,\n  ...props\n}: React.ComponentProps<typeof BaseToolbar.Separator>) {\n  return (\n    <BaseToolbar.Separator\n      data-slot=\"toolbar-separator\"\n      // Base UI sets the separator's OWN orientation, perpendicular to the\n      // toolbar's: a horizontal bar gets a vertical rule.\n      className={cn(\n        'bg-border shrink-0',\n        'data-[orientation=vertical]:mx-1 data-[orientation=vertical]:h-5 data-[orientation=vertical]:w-px',\n        'data-[orientation=horizontal]:my-1 data-[orientation=horizontal]:h-px data-[orientation=horizontal]:w-full',\n        className,\n      )}\n      {...props}\n    />\n  );\n}\n\nfunction ToolbarInput({ className, ...props }: React.ComponentProps<typeof BaseToolbar.Input>) {\n  return (\n    <BaseToolbar.Input\n      data-slot=\"toolbar-input\"\n      className={cn(\n        'border-input bg-background text-foreground placeholder:text-muted-foreground h-control-sm min-w-0 rounded-lg border px-2.5 text-sm shadow-xs focus-visible:outline-hidden',\n        'focus-visible:border-ring focus-visible:ring-ring focus-visible:ring-2 focus-visible:ring-offset-2 focus-visible:ring-offset-background',\n        'disabled:cursor-not-allowed disabled:opacity-50',\n        className,\n      )}\n      {...props}\n    />\n  );\n}\n\nexport { Toolbar, ToolbarButton, ToolbarLink, ToolbarGroup, ToolbarSeparator, ToolbarInput };\nexport type { ToolbarButtonProps };\n"
    },
    {
      "path": "registry/interlace-ui/button-variants.ts",
      "target": "components/ui/button-variants.ts",
      "type": "registry:ui",
      "content": "import { cva, type VariantProps } from 'class-variance-authority';\n\n// @interlace/button-variants v3.5.1 — Interlace design system.\n// Docs, props and live preview: https://ds.interlace.tools/c/button-variants\n// What changed since: https://ds.interlace.tools/c/button-variants#history\n// Generated banner — keep it, the upgrade diff reads this version.\n\n/**\n * @interlace/ui — buttonVariants\n *\n * The cva variant map that `button.tsx` imports — variant × size class strings\n * and nothing else. Pure CVA: no React, no client APIs, so a server component\n * can style a plain `<a>` with `buttonVariants({ variant, size })`.\n *\n * This is not a component. It exports a function and a type, renders nothing,\n * and has no props, no slots and no DOM — which is exactly why it is a\n * separate module from the `'use client'` Button that consumes it.\n *\n * ## Anatomy\n *\n *   buttonVariants({ variant, size })\n *     ├─ variant    default | highlight | destructive | outline | secondary | ghost | link\n *     ├─ size       default | xs | sm | lg | icon | icon-xs | icon-sm | icon-lg\n *     └─ fullWidth  boolean — stretches to its container (default false)\n *\n * Defaults are `variant: 'default'`, `size: 'default'`. `pagination.tsx` is\n * the in-repo example of styling an element rather than nesting a Button: its\n * `<a>` takes `buttonVariants({ variant, size })` directly. (It reaches the\n * function through `button.js`, which re-exports it — that path is\n * `'use client'`; import from this module to keep a server tree server-side.)\n *\n * ## Why half this file is comments\n *\n * Four of the seven variants carry a long note recording a measured contrast\n * failure and the rule it produced: a variant that declares its own foreground\n * must paint an opaque surface in the same state, because a button is dropped\n * onto surfaces the design system does not control. `outline` inheriting the\n * page text into a `bg-primary` section measured 1.05:1; `link` with\n * `text-primary` on the same section measured 1.00:1. `composite-contrast-lock`\n * composites every variant over every brandable backdrop, so those notes are\n * checkable rather than folklore.\n *\n * | Rule | Concept                          | Where in this file                                          |\n * | ---- | -------------------------------- | ----------------------------------------------------------- |\n * | R8   | Enums, no booleans               | `variant` and `size` are closed string enums                |\n * | R19  | Tokens only                      | `bg-primary`, `bg-destructive`, `bg-accent`, `ring-ring` |\n * | R20  | AA contrast                      | every pair composited by `composite-contrast-lock`          |\n * | R25  | Server-safe                      | no React import, no hooks, no `'use client'`                |\n */\n\n// Server-safe button variants. The full `<Button>` component lives in\n// `./button.tsx` and is `'use client'` (Base UI useRender). Variants are a\n// pure CVA function — no React, no client APIs — so they can be called\n// from server components when composing className strings (e.g. on a\n// `<Link className={buttonVariants(...)}>` in a server-rendered page).\n\nconst buttonVariants = cva(\n  \"relative isolate inline-flex items-center justify-center gap-2 whitespace-nowrap rounded-lg text-sm font-medium transition-[color,background-color,border-color,box-shadow,scale] duration-(--duration-fast) ease-enter motion-safe:active:scale-[0.97] disabled:pointer-events-none disabled:opacity-50 [&_svg]:pointer-events-none [&_svg:not([class*='size-'])]:size-4 shrink-0 [&_svg]:shrink-0 focus-visible:outline-hidden focus-visible:border-ring focus-visible:ring-ring focus-visible:ring-2 focus-visible:ring-offset-2 focus-visible:ring-offset-background aria-invalid:ring-destructive/20 dark:aria-invalid:ring-destructive/40 aria-invalid:border-destructive\",\n  {\n    variants: {\n      variant: {\n        default: 'bg-primary text-primary-foreground hover:bg-primary/90',\n        // The warm call-to-action that is NOT the brand primary: the second\n        // button on a hero, \"start here\" beside a primary \"sign up\". Opaque\n        // face plus its own foreground, so it holds on any section surface.\n        highlight:\n          'bg-highlight text-highlight-foreground hover:bg-highlight/90',\n        // No `dark:bg-destructive/60` here, unlike stock shadcn — see the\n        // matching note in badge.tsx. Our dark destructive token is a light\n        // red tuned for AAA on near-black; muting it to 60% drops the label\n        // to 4.27:1, under AA. Caught by composite-contrast-lock.\n        destructive:\n          'bg-destructive text-destructive-foreground hover:bg-destructive/90 focus-visible:ring-destructive',\n        // `text-foreground` is NOT redundant, and neither is the ABSENCE of\n        // stock shadcn's `dark:bg-input/30` / `dark:hover:bg-input/50`. Both\n        // halves of that come from the same shipped defect, found twice.\n        //\n        // First half: `outline` paints an opaque surface (`bg-background`)\n        // but was the only such variant that did not also set a foreground,\n        // so it INHERITED one. Dropped inside a section that flips the text\n        // colour — `<CTASection tone=\"primary\">` is `bg-primary\n        // text-primary-foreground` — the button kept the page background and\n        // took the section's white text: 1.05:1, invisible.\n        //\n        // Second half: declaring a foreground only means something if the\n        // surface under it is actually opaque. `dark:bg-input/30` overrode\n        // `bg-background` with a 30% tint, so in dark mode the same\n        // `bg-primary` section bled through — `#6b635a` at 30% over `#fbb99a`\n        // composites to `#d09f87`, and `text-foreground` `#f0ede9` lands on\n        // that at 2.00:1. The hover state was worse-shaped and identical in\n        // result (`dark:hover:bg-input/50` + `hover:text-accent-foreground`,\n        // 2.00:1). Dropping both makes dark match what light already did:\n        // no fill, the control identified by its border — `dark:border-input`\n        // is 3.35:1 on the dark background, clearing SC 1.4.11.\n        //\n        // The rule, stated so it is checkable: a variant that declares its own\n        // foreground must paint an opaque surface in the same state, because\n        // a button is dropped onto surfaces the DS does not control. Locked by\n        // composite-contrast-lock, which composites every variant over every\n        // brandable backdrop rather than over the page background.\n        outline:\n          'border bg-background text-foreground shadow-xs hover:bg-accent hover:text-accent-foreground dark:border-input',\n        secondary:\n          'bg-secondary text-secondary-foreground hover:bg-secondary/80',\n        // No `dark:hover:bg-accent/50` here, for the reason spelled out on\n        // `outline`: it declares `hover:text-accent-foreground`, so a 50% hover\n        // surface let a `bg-primary` section through at 3.07:1. Opaque\n        // `bg-accent` carries its own foreground at 10.46:1 in both schemes.\n        // At rest `ghost` declares neither colour and inherits both, which is\n        // the variant's whole point and is safe anywhere.\n        ghost: 'hover:bg-accent hover:text-accent-foreground',\n        // Inherits its colour, and is underlined at rest rather than only on\n        // hover. Stock shadcn is `text-primary … hover:underline`, which is\n        // the same defect as the two above in its purest form: a declared\n        // foreground over a surface the variant does not paint. `text-primary`\n        // on a `<CTASection tone=\"primary\">` is `#7d350c` on `#7d350c` —\n        // 1.00:1, the button is literally the same colour as the section.\n        //\n        // A variant with no surface of its own cannot name a colour; the only\n        // safe foreground is the inherited one, which is by construction the\n        // pair its surface was measured with. That leaves the underline to\n        // carry the affordance, so it has to be there at rest — which also\n        // retires a colour-only link cue (WCAG 1.4.1) and matches how `Prose`\n        // already renders links. `decoration-from-font` is Prose's too; hover\n        // thickens the rule instead of shifting the hue, because any hue we\n        // could shift to reintroduces the bug.\n        // A link does not press like a button: it keeps its size.\n        link: 'underline underline-offset-4 decoration-from-font hover:decoration-2 motion-safe:active:scale-100',\n      },\n      size: {\n        default: 'h-control px-4 py-2 has-[>svg]:px-3',\n        xs: \"h-control-xs gap-1 rounded-lg px-2 text-xs has-[>svg]:px-1.5 [&_svg:not([class*='size-'])]:size-3\",\n        sm: 'h-control-sm rounded-lg gap-1.5 px-3 has-[>svg]:px-2.5',\n        lg: 'h-control-lg rounded-lg px-6 has-[>svg]:px-4',\n        icon: 'size-control',\n        'icon-xs': \"size-control-xs rounded-lg [&_svg:not([class*='size-'])]:size-3\",\n        'icon-sm': 'size-control-sm',\n        'icon-lg': 'size-control-lg',\n      },\n      // R8: a boolean, default false, no `is` prefix. Replaces `className=\"w-full\"`\n      // at call sites (sign-in-form, newsletter-form) — MUI `fullWidth`, Primer `block`.\n      fullWidth: {\n        true: 'w-full',\n        false: '',\n      },\n    },\n    defaultVariants: {\n      variant: 'default',\n      size: 'default',\n      fullWidth: false,\n    },\n  },\n);\n\nexport { buttonVariants };\nexport type { VariantProps };\n"
    }
  ],
  "meta": {
    "tier": "primitive",
    "client": true,
    "minViewport": 320,
    "loading": false,
    "version": "3.6.1",
    "since": "2.0.0"
  },
  "docs": "## @interlace/toolbar\n\nInstalled to `components/ui/toolbar.tsx`.\n\n```tsx\nimport { /* … */ } from '@/components/ui/toolbar';\n```\n\nProps, a11y contract, live preview and source: https://ds.interlace.tools/c/toolbar\n\nRequires the `@interlace/interlace-base` CSS baseline (installed automatically as a registry dependency). For the Interlace look, also add `@interlace/theme`."
}
