{
  "$schema": "https://ui.shadcn.com/schema/registry-item.json",
  "name": "tabs",
  "type": "registry:ui",
  "title": "Tabs",
  "description": "Tabs organise content into named sections that the user can switch between without leaving the page.",
  "dependencies": [
    "@radix-ui/react-compose-refs@^1.1.3",
    "@radix-ui/react-tabs@^1.1.13",
    "@remixicon/react@^4.9.0",
    "class-variance-authority@^0.7.1"
  ],
  "registryDependencies": [
    "https://wideset.co/r/icon-types.json",
    "https://wideset.co/r/motion.json",
    "https://wideset.co/r/status-badge.json",
    "https://wideset.co/r/styles.json",
    "https://wideset.co/r/utils.json"
  ],
  "files": [
    {
      "path": "src/components/tabs/Tabs.context.ts",
      "type": "registry:ui",
      "target": "components/ui/wideset/tabs/Tabs.context.ts",
      "content": "'use client';\n\nimport { createContext, useContext } from 'react';\n\nimport type { TabsContextValue } from './Tabs.types';\n\nexport const TabsContext = createContext<TabsContextValue | undefined>(undefined);\n\nexport const useTabsContext = () => {\n  const context = useContext(TabsContext);\n\n  if (context === undefined) {\n    throw new Error('useTabsContext must be used within a <Tabs>');\n  }\n\n  return context;\n};\n"
    },
    {
      "path": "src/components/tabs/Tabs.hooks.tsx",
      "type": "registry:ui",
      "target": "components/ui/wideset/tabs/Tabs.hooks.tsx",
      "content": "'use client';\n\nimport { useLayoutEffect, useState } from 'react';\n\nexport type TabsIndicator = {\n  x: number;\n  width: number;\n  visible: boolean;\n  animate: boolean;\n};\n\nconst isSameIndicator = (a: TabsIndicator, b: TabsIndicator) =>\n  (Object.keys(a) as (keyof TabsIndicator)[]).every((key) => a[key] === b[key]);\n\nexport const useTabsIndicator = (enabled: boolean) => {\n  const [node, setNode] = useState<HTMLDivElement | null>(null);\n  const [indicator, setIndicator] = useState<TabsIndicator | null>(null);\n\n  useLayoutEffect(() => {\n    if (!enabled || !node) return;\n\n    const controller = new AbortController();\n    const { signal } = controller;\n    let lastActive: HTMLElement | null = null;\n    let fromKeyboard = false;\n\n    const resizeObserver = new ResizeObserver(() => measure());\n\n    const measure = () => {\n      node.querySelectorAll('[role=\"tab\"]').forEach((item) => resizeObserver.observe(item));\n\n      const active =\n        node.querySelector<HTMLElement>('[data-active]') ??\n        node.querySelector<HTMLElement>('[role=\"tab\"][data-state=\"active\"]');\n      if (!active) {\n        setIndicator((previous) => previous && { ...previous, visible: false });\n        return;\n      }\n\n      const moved = lastActive !== null && lastActive !== active;\n      lastActive = active;\n\n      const next: TabsIndicator = {\n        x: active.offsetLeft,\n        width: active.offsetWidth,\n        visible: !active.hasAttribute('data-disabled'),\n        animate: moved && !fromKeyboard,\n      };\n      setIndicator((previous) => (previous && isSameIndicator(previous, next) ? previous : next));\n    };\n\n    const mutationObserver = new MutationObserver(measure);\n\n    measure();\n    resizeObserver.observe(node);\n    mutationObserver.observe(node, {\n      subtree: true,\n      childList: true,\n      attributes: true,\n      attributeFilter: ['data-state', 'data-active', 'data-disabled'],\n    });\n    node.addEventListener('keydown', () => (fromKeyboard = true), { signal });\n    node.addEventListener('pointerdown', () => (fromKeyboard = false), { signal });\n    document.fonts?.ready.then(() => !signal.aborted && measure());\n\n    return () => {\n      controller.abort();\n      resizeObserver.disconnect();\n      mutationObserver.disconnect();\n    };\n  }, [enabled, node]);\n\n  return { ref: setNode, indicator };\n};\n"
    },
    {
      "path": "src/components/tabs/Tabs.tsx",
      "type": "registry:ui",
      "target": "components/ui/wideset/tabs/Tabs.tsx",
      "content": "'use client';\n\nimport * as RadixTabs from '@radix-ui/react-tabs';\nimport { cn } from '@/lib/wideset/utils';\n\nimport { useDefaultMotion } from '@/lib/wideset/motion/MotionProvider';\nimport { TabsContext } from './Tabs.context';\nimport type { TabsProps } from './Tabs.types';\nimport { tabsVariants } from './Tabs.variants';\nimport { TabsContent } from './TabsContent';\nimport { TabsCount } from './TabsCount';\nimport { TabsIcon } from './TabsIcon';\nimport { TabsItem } from './TabsItem';\nimport { TabsLabel } from './TabsLabel';\nimport { TabsList } from './TabsList';\n\nconst Tabs = ({\n  children,\n  size,\n  type,\n  divider = true,\n  className,\n  disabled,\n  defaultMotion,\n  ...props\n}: TabsProps) => {\n  const motion = useDefaultMotion(defaultMotion);\n\n  return (\n    <TabsContext.Provider value={{ size, type, divider, disabled, motion }}>\n      <RadixTabs.Root\n        data-slot=\"tabs\"\n        className={cn(tabsVariants({ size, type }), className)}\n        {...props}\n      >\n        {children}\n      </RadixTabs.Root>\n    </TabsContext.Provider>\n  );\n};\n\nTabs.displayName = 'Tabs';\nTabs.Icon = TabsIcon;\nTabs.Label = TabsLabel;\nTabs.Count = TabsCount;\nTabs.List = TabsList;\nTabs.Item = TabsItem;\nTabs.Content = TabsContent;\n\nexport { Tabs };\n"
    },
    {
      "path": "src/components/tabs/Tabs.types.ts",
      "type": "registry:ui",
      "target": "components/ui/wideset/tabs/Tabs.types.ts",
      "content": "import type * as RadixTabs from '@radix-ui/react-tabs';\nimport type { RemixiconComponentType } from '@remixicon/react';\nimport type { VariantProps } from 'class-variance-authority';\nimport type { ComponentProps } from 'react';\n\nimport type { MotionProps } from '@/lib/wideset/motion/Motion.types';\nimport type { RemixiconProps } from '@/lib/wideset/icon.types';\nimport type { tabsVariants } from './Tabs.variants';\n\nexport type TabsSize = VariantProps<typeof tabsVariants>['size'];\nexport type TabsType = VariantProps<typeof tabsVariants>['type'];\n\nexport type TabsContextValue = {\n  size: TabsSize;\n  type: TabsType;\n  divider?: boolean;\n  disabled?: boolean;\n  motion: boolean;\n};\n\n/** Named sections displayed one at a time. */\nexport type TabsProps = {\n  /**\n   * Visual style variant of the tabs.\n   * - `regular` — underline indicator, tabs aligned to content width\n   * - `fullWidth` — underline indicator, tabs stretch to fill the container\n   * - `pills` — pill-shaped tabs with background fill on the active item\n   * - `ghost` — borderless tabs; a soft background slides to the active item\n   */\n  type?: TabsType;\n  /**\n   * Size of the tabs, controls label typography and padding.\n   * @default 'sm'\n   */\n  size?: TabsSize;\n  /**\n   * Whether to render a bottom border beneath the tab list.\n   * Ignored when `type` is `pills` or `ghost`.\n   * @default true\n   */\n  divider?: boolean;\n  /**\n   * Disables all tab items. Individual items can still be disabled via `Tabs.Item`.\n   * @default false\n   */\n  disabled?: boolean;\n} & MotionProps &\n  Omit<ComponentProps<typeof RadixTabs.Root>, 'size'>;\n\n/** The container arranging tab triggers. */\nexport type TabsListProps = ComponentProps<typeof RadixTabs.List>;\n\n/** An individual item within `Tabs`. */\nexport type TabsItemProps = ComponentProps<typeof RadixTabs.Trigger> & {\n  /** The value that identifies this tab. */\n  value: string;\n  /** Forces the active visual state — useful when using `asChild` with router links. */\n  active?: boolean;\n  /** Disables this specific tab item. Overrides the parent `Tabs` `disabled` prop. */\n  disabled?: boolean;\n};\n\n/** The content surface rendered within `Tabs`. */\nexport type TabsContentProps = ComponentProps<typeof RadixTabs.Content>;\n\n/** The text label associated with `Tabs`. */\nexport type TabsLabelProps = React.HTMLAttributes<HTMLSpanElement>;\n\n/** A count displayed beside a tab label. */\nexport type TabsCountProps = {\n  /** Count displayed inside the badge. */\n  children?: React.ReactNode;\n  /** Additional CSS classes for layout overrides. */\n  className?: string;\n};\n\n/** An icon rendered within `Tabs`. */\nexport type TabsIconProps = RemixiconProps & {\n  /** Icon component to render. */\n  icon: RemixiconComponentType;\n  /** Renders the icon in a muted colour to signal the disabled state. */\n  disabled?: boolean;\n};\n"
    },
    {
      "path": "src/components/tabs/Tabs.variants.ts",
      "type": "registry:ui",
      "target": "components/ui/wideset/tabs/Tabs.variants.ts",
      "content": "import { cva } from 'class-variance-authority';\nimport { cn } from '@/lib/wideset/utils';\n\nimport { hoverTintMotion, pressMotion } from '@/lib/wideset/motion/recipes';\n\nexport const tabsVariants = cva(`text-ws-static-base flex flex-col`, {\n  variants: {\n    type: {\n      regular: '',\n      fullWidth: 'w-full flex-1 justify-stretch',\n      pills: '',\n      ghost: '',\n    },\n    size: {\n      sm: '',\n      lg: '',\n    },\n  },\n  defaultVariants: {\n    type: 'regular',\n    size: 'sm',\n  },\n});\n\nexport const tabsListVariants = cva('relative flex', {\n  variants: {\n    type: {\n      regular: 'gap-ws-12 w-fit',\n      fullWidth: 'w-full justify-stretch',\n      pills: 'gap-ws-5 w-fit',\n      ghost: 'gap-ws-3 isolate w-fit',\n    },\n    size: {\n      sm: '',\n      lg: '',\n    },\n  },\n  defaultVariants: {\n    type: 'regular',\n    size: 'sm',\n  },\n});\n\nexport const tabsIndicatorVariants = cva('pointer-events-none absolute left-0', {\n  variants: {\n    type: {\n      regular: 'bottom-[-1px] h-[2px] bg-(--border-color-ws-dynamic-secondary-strong-default)',\n      fullWidth: 'bottom-[-1px] h-[2px] bg-(--border-color-ws-dynamic-secondary-strong-default)',\n      pills: 'hidden',\n      ghost:\n        'rounded-ws-control-lg bg-ws-dynamic-tertiary-alpha-strong-default inset-y-0 -z-[var(--ws-z-index-base)]',\n    },\n    animate: {\n      true: 'transition-[transform,width,opacity] duration-(--ws-motion-duration-fast) ease-(--ws-motion-ease-smooth-out)',\n      false: '',\n    },\n  },\n  defaultVariants: { type: 'regular' },\n});\n\nexport const tabsItemVariants = cva(\n  cn(\n    'text-ws-static-base focus-visible:wds-focus-visible outline-ws-dynamic-primary-strong-default box-border flex cursor-pointer items-center justify-center',\n    'disabled:text-ws-static-subtle disabled:pointer-events-none disabled:cursor-not-allowed',\n  ),\n  {\n    variants: {\n      type: {\n        regular: cn(\n          'mb-[-1px] border-b-2 border-b-transparent',\n          'hover:border-ws-dynamic-secondary-hover',\n        ),\n        fullWidth: cn(\n          'px-ws-9 mb-[-1px] flex-1 border-b-2 border-b-transparent',\n          'hover:border-ws-dynamic-secondary-hover',\n        ),\n        pills: cn(\n          'rounded-ws-control-full border-ws-dynamic-secondary-default border-1',\n          'hover:border-ws-dynamic-secondary-hover',\n          'aria-selected:not-focus-visible:bg-ws-dynamic-primary-alpha-strong-default aria-selected:text-ws-dynamic-primary-default! aria-selected:border-transparent!',\n          'data-active:not-focus-visible:bg-ws-dynamic-primary-alpha-strong-default data-active:text-ws-dynamic-primary-default! data-active:border-transparent!',\n        ),\n        ghost: cn(\n          'rounded-ws-control-lg text-ws-static-subtle hover:text-ws-static-strong',\n          '[&_svg]:text-current',\n          'aria-selected:text-ws-static-strong data-active:text-ws-static-strong',\n        ),\n      },\n      size: {\n        sm: 'typography-label-strong-sm',\n        lg: 'typography-label-strong-md',\n      },\n    },\n    compoundVariants: [\n      {\n        type: ['regular', 'fullWidth'],\n        size: 'sm',\n        className: 'gap-ws-3 pt-ws-6 pb-ws-5',\n      },\n      {\n        type: ['regular', 'fullWidth'],\n        size: 'lg',\n        className: 'gap-ws-5 pt-ws-8 pb-ws-7',\n      },\n      {\n        type: 'pills',\n        size: 'sm',\n        className: 'gap-ws-2 px-ws-5 py-ws-4',\n      },\n      {\n        type: 'pills',\n        size: 'lg',\n        className: 'gap-ws-3 px-ws-9 py-ws-5',\n      },\n      {\n        type: 'ghost',\n        size: 'sm',\n        className: 'gap-ws-4 px-ws-7 py-ws-4',\n      },\n      {\n        type: 'ghost',\n        size: 'lg',\n        className: 'gap-ws-6 px-ws-9 py-ws-5',\n      },\n    ],\n    defaultVariants: {\n      type: 'regular',\n      size: 'sm',\n    },\n  },\n);\n\nexport const tabsItemMotionVariants = cva('', {\n  variants: {\n    enabled: {\n      true: cn(hoverTintMotion, pressMotion),\n      false: '',\n    },\n  },\n  defaultVariants: { enabled: true },\n});\n"
    },
    {
      "path": "src/components/tabs/TabsContent.tsx",
      "type": "registry:ui",
      "target": "components/ui/wideset/tabs/TabsContent.tsx",
      "content": "'use client';\n\nimport * as RadixTabs from '@radix-ui/react-tabs';\nimport { forwardRef } from 'react';\n\nimport type { TabsContentProps } from './Tabs.types';\n\nconst TabsContent = forwardRef<HTMLDivElement, TabsContentProps>((props, ref) => (\n  <RadixTabs.Content ref={ref} data-slot=\"tabs-content\" {...props} />\n));\n\nTabsContent.displayName = 'Tabs.Content';\n\nexport { TabsContent };\n"
    },
    {
      "path": "src/components/tabs/TabsCount.tsx",
      "type": "registry:ui",
      "target": "components/ui/wideset/tabs/TabsCount.tsx",
      "content": "'use client';\n\nimport { StatusBadge } from '@/components/ui/wideset/status-badge/StatusBadge';\nimport { cn } from '@/lib/wideset/utils';\n\nimport { useTabsContext } from './Tabs.context';\nimport type { TabsCountProps } from './Tabs.types';\n\nconst TabsCount = ({ children, className }: TabsCountProps) => {\n  const { type, size } = useTabsContext();\n\n  // At sm Figma nests the icon and label in a `Label` frame with Gap/3, while the\n  // count sits outside it at the item's Gap/5. The item carries the smaller gap, so\n  // the count makes up the 4px difference itself.\n  const isUnderlined = type !== 'pills';\n  const needsOffset = isUnderlined && size !== 'lg';\n\n  return (\n    <StatusBadge\n      data-slot=\"tabs-count\"\n      color=\"neutral\"\n      emphasis=\"low\"\n      shape=\"rounded\"\n      size=\"sm\"\n      className={cn(needsOffset && 'ml-ws-3', className)}\n    >\n      {children}\n    </StatusBadge>\n  );\n};\n\nTabsCount.displayName = 'Tabs.Count';\n\nexport { TabsCount };\n"
    },
    {
      "path": "src/components/tabs/TabsIcon.tsx",
      "type": "registry:ui",
      "target": "components/ui/wideset/tabs/TabsIcon.tsx",
      "content": "'use client';\n\nimport { cn } from '@/lib/wideset/utils';\n\nimport type { TabsIconProps } from './Tabs.types';\n\nconst TabsIcon = ({ icon: Icon, className, disabled, ...props }: TabsIconProps) => (\n  <Icon\n    aria-hidden=\"true\"\n    focusable=\"false\"\n    className={cn(\n      'size-ws-9',\n      disabled ? 'text-ws-static-subtle' : 'text-ws-static-base',\n      className,\n    )}\n    data-slot=\"tabs-icon\"\n    {...props}\n  />\n);\n\nTabsIcon.displayName = 'Tabs.Icon';\n\nexport { TabsIcon };\n"
    },
    {
      "path": "src/components/tabs/TabsItem.tsx",
      "type": "registry:ui",
      "target": "components/ui/wideset/tabs/TabsItem.tsx",
      "content": "'use client';\n\nimport * as RadixTabs from '@radix-ui/react-tabs';\nimport { cn } from '@/lib/wideset/utils';\n\nimport { useTabsContext } from './Tabs.context';\nimport type { TabsItemProps } from './Tabs.types';\nimport { tabsItemMotionVariants, tabsItemVariants } from './Tabs.variants';\n\nconst TabsItem = ({\n  className,\n  children,\n  disabled: propDisabled,\n  active,\n  ...props\n}: TabsItemProps) => {\n  const { type, size, disabled: contextDisabled, motion } = useTabsContext();\n  const disabled = propDisabled || contextDisabled;\n\n  return (\n    <RadixTabs.Trigger\n      className={cn(\n        tabsItemVariants({ type, size }),\n        tabsItemMotionVariants({ enabled: motion }),\n        className,\n      )}\n      disabled={disabled}\n      data-active={active ? '' : undefined}\n      data-slot=\"tabs-item\"\n      {...props}\n    >\n      {children}\n    </RadixTabs.Trigger>\n  );\n};\n\nTabsItem.displayName = 'Tabs.Item';\n\nexport { TabsItem };\n"
    },
    {
      "path": "src/components/tabs/TabsLabel.tsx",
      "type": "registry:ui",
      "target": "components/ui/wideset/tabs/TabsLabel.tsx",
      "content": "'use client';\n\nimport type { TabsLabelProps } from './Tabs.types';\n\nconst TabsLabel = ({ children, ...props }: TabsLabelProps) => (\n  <span data-slot=\"tabs-label\" {...props}>\n    {children}\n  </span>\n);\n\nTabsLabel.displayName = 'Tabs.Label';\n\nexport { TabsLabel };\n"
    },
    {
      "path": "src/components/tabs/TabsList.tsx",
      "type": "registry:ui",
      "target": "components/ui/wideset/tabs/TabsList.tsx",
      "content": "'use client';\n\nimport { useComposedRefs } from '@radix-ui/react-compose-refs';\nimport * as RadixTabs from '@radix-ui/react-tabs';\nimport { cn } from '@/lib/wideset/utils';\n\nimport { useTabsContext } from './Tabs.context';\nimport { useTabsIndicator } from './Tabs.hooks';\nimport type { TabsListProps } from './Tabs.types';\nimport { tabsIndicatorVariants, tabsListVariants } from './Tabs.variants';\n\nconst TabsList = ({ className, children, ref, ...props }: TabsListProps) => {\n  const { size, type, divider, motion } = useTabsContext();\n  const travels = type !== 'pills';\n  const underline = travels && type !== 'ghost';\n  const { ref: indicatorRef, indicator } = useTabsIndicator(travels);\n  const composedRef = useComposedRefs(ref, indicatorRef);\n\n  return (\n    <RadixTabs.List\n      ref={composedRef}\n      className={cn(\n        tabsListVariants({ size, type }),\n        { 'border-ws-static-subtle border-b': divider && underline },\n        className,\n      )}\n      data-slot=\"tabs-list\"\n      {...props}\n    >\n      {children}\n      {travels && indicator && (\n        <span\n          aria-hidden\n          className={cn(\n            tabsIndicatorVariants({ type, animate: motion && indicator.animate }),\n            !indicator.visible && 'opacity-0',\n          )}\n          style={{ width: indicator.width, transform: `translateX(${indicator.x}px)` }}\n        />\n      )}\n    </RadixTabs.List>\n  );\n};\n\nTabsList.displayName = 'Tabs.List';\n\nexport { TabsList };\n"
    }
  ],
  "meta": {
    "version": "1.0.0",
    "commit": "8bb3627"
  }
}
