{
  "$schema": "https://ui.shadcn.com/schema/registry-item.json",
  "name": "mobile-tab-bar",
  "title": "Mobile Tab Bar",
  "description": "A bottom navigation bar for phones: a pill slides behind the active tab and its icon bounces, with badge counts, an optional raised centre action, docked or floating styles, blurred glass and safe-area padding.",
  "dependencies": [
    "motion",
    "clsx",
    "tailwind-merge"
  ],
  "files": [
    {
      "path": "registry/new-york/mobile-tab-bar/mobile-tab-bar.tsx",
      "content": "\"use client\";\n\nimport * as React from \"react\";\nimport { motion, AnimatePresence, useReducedMotion } from \"motion/react\";\nimport { clsx, type ClassValue } from \"clsx\";\nimport { twMerge } from \"tailwind-merge\";\n\nfunction cn(...inputs: ClassValue[]) {\n  return twMerge(clsx(inputs));\n}\n\nexport type MobileTabBarVariant = \"docked\" | \"floating\";\nexport type MobileTabBarSize = \"sm\" | \"md\" | \"lg\";\n\nexport interface MobileTabBarItem {\n  id: string;\n  label: string;\n  icon: React.ReactNode;\n  /** A number shows as a count (99+ above 99); true shows a dot. */\n  badge?: number | boolean;\n  href?: string;\n}\n\nexport interface MobileTabBarAction {\n  label: string;\n  icon?: React.ReactNode;\n  onClick?: () => void;\n}\n\nexport interface MobileTabBarProps {\n  items?: MobileTabBarItem[];\n  value?: string;\n  defaultValue?: string;\n  onValueChange?: (id: string) => void;\n  /** A raised round button in the middle of the bar, e.g. \"New post\". */\n  centerAction?: MobileTabBarAction;\n  /** docked sits flush with the bottom edge; floating is a rounded bar hovering above it. */\n  variant?: MobileTabBarVariant;\n  labels?: \"always\" | \"active\" | \"none\";\n  /** Pins the bar to the viewport's bottom; turn off to place it inside a container. */\n  fixed?: boolean;\n  size?: MobileTabBarSize;\n  theme?: \"dark\" | \"light\";\n  className?: string;\n}\n\nconst PALETTES = {\n  dark: { text: \"#F5F4F1\", muted: \"rgba(245,244,241,0.5)\", bar: \"rgba(16,16,16,0.82)\", border: \"rgba(255,255,255,0.1)\", pill: \"rgba(255,255,255,0.1)\", action: \"#F5F4F1\", actionFg: \"#0A0A0A\", badge: \"#FF7A6B\", badgeFg: \"#0A0A0A\", ring: \"#101010\", focus: \"rgba(245,244,241,0.85)\", shadow: \"0 12px 40px rgba(0,0,0,0.5)\" },\n  light: { text: \"#0A0A0A\", muted: \"rgba(10,10,10,0.5)\", bar: \"rgba(255,255,255,0.86)\", border: \"rgba(10,10,10,0.1)\", pill: \"rgba(10,10,10,0.07)\", action: \"#0A0A0A\", actionFg: \"#FFFFFF\", badge: \"#E5484D\", badgeFg: \"#FFFFFF\", ring: \"#FFFFFF\", focus: \"rgba(10,10,10,0.85)\", shadow: \"0 12px 40px rgba(10,10,10,0.14)\" },\n};\n\nconst SIZES: Record<MobileTabBarSize, { height: number; icon: number; font: number; action: number }> = {\n  sm: { height: 56, icon: 20, font: 10, action: 46 },\n  md: { height: 64, icon: 22, font: 10.5, action: 52 },\n  lg: { height: 72, icon: 24, font: 11.5, action: 58 },\n};\n\nconst svg = (d: string) => (\n  <svg width=\"100%\" height=\"100%\" viewBox=\"0 0 24 24\" fill=\"none\" stroke=\"currentColor\" strokeWidth=\"1.7\" strokeLinecap=\"round\" strokeLinejoin=\"round\" aria-hidden=\"true\">\n    <path d={d} />\n  </svg>\n);\n\nconst DEFAULT_ITEMS: MobileTabBarItem[] = [\n  { id: \"home\", label: \"Home\", icon: svg(\"M3.5 10.5 12 3.5l8.5 7V20a1 1 0 0 1-1 1h-5v-6h-5v6h-5a1 1 0 0 1-1-1z\") },\n  { id: \"search\", label: \"Search\", icon: svg(\"M11 18a7 7 0 1 0 0-14 7 7 0 0 0 0 14zM20.5 20.5 16 16\") },\n  { id: \"inbox\", label: \"Inbox\", icon: svg(\"M3.5 13.5 6 5h12l2.5 8.5V19a1 1 0 0 1-1 1h-15a1 1 0 0 1-1-1zM3.5 13.5h5l1.5 2.5h4l1.5-2.5h5\"), badge: 3 },\n  { id: \"profile\", label: \"Profile\", icon: svg(\"M12 12a4 4 0 1 0 0-8 4 4 0 0 0 0 8zM4.5 20.5c.9-3.5 3.9-5.5 7.5-5.5s6.6 2 7.5 5.5\") },\n];\n\nexport function MobileTabBar({\n  items = DEFAULT_ITEMS,\n  value,\n  defaultValue,\n  onValueChange,\n  centerAction,\n  variant = \"floating\",\n  labels = \"always\",\n  fixed = true,\n  size = \"md\",\n  theme = \"dark\",\n  className,\n}: MobileTabBarProps) {\n  const p = PALETTES[theme];\n  const s = SIZES[size];\n  const uid = React.useId();\n  const reduce = Boolean(useReducedMotion());\n  const [internal, setInternal] = React.useState(defaultValue ?? items[0]?.id);\n  const current = value ?? internal;\n  const floating = variant === \"floating\";\n\n  const select = (id: string) => {\n    if (value === undefined) setInternal(id);\n    onValueChange?.(id);\n  };\n\n  // With a centre action the tabs split into two halves around it.\n  const half = Math.ceil(items.length / 2);\n  const slots: (MobileTabBarItem | \"action\")[] = centerAction ? [...items.slice(0, half), \"action\", ...items.slice(half)] : items;\n\n  const onKey = (e: React.KeyboardEvent) => {\n    if (e.key !== \"ArrowLeft\" && e.key !== \"ArrowRight\" && e.key !== \"Home\" && e.key !== \"End\") return;\n    const tabs = Array.from((e.currentTarget as HTMLElement).querySelectorAll<HTMLElement>(\"[data-tab]\"));\n    const i = tabs.indexOf(document.activeElement as HTMLElement);\n    const next = e.key === \"Home\" ? 0 : e.key === \"End\" ? tabs.length - 1 : (i + (e.key === \"ArrowRight\" ? 1 : -1) + tabs.length) % tabs.length;\n    e.preventDefault();\n    tabs[next]?.focus();\n  };\n\n  return (\n    <nav\n      aria-label=\"Main\"\n      className={cn(fixed ? \"fixed\" : \"absolute\", \"inset-x-0 bottom-0 z-40\", className)}\n      style={{ padding: floating ? `0 14px calc(12px + env(safe-area-inset-bottom, 0px))` : 0, fontFamily: \"Inter, sans-serif\", pointerEvents: \"none\" }}\n    >\n      <ul\n        onKeyDown={onKey}\n        className=\"m-0 flex list-none items-stretch p-0\"\n        style={{\n          pointerEvents: \"auto\",\n          height: s.height,\n          padding: floating ? 5 : \"0 6px\",\n          paddingBottom: floating ? 5 : \"env(safe-area-inset-bottom, 0px)\",\n          boxSizing: \"content-box\",\n          background: p.bar,\n          backdropFilter: \"blur(18px) saturate(160%)\",\n          WebkitBackdropFilter: \"blur(18px) saturate(160%)\",\n          border: floating ? `1px solid ${p.border}` : undefined,\n          borderTop: `1px solid ${p.border}`,\n          borderRadius: floating ? s.height : 0,\n          boxShadow: floating ? p.shadow : undefined,\n        }}\n      >\n        {slots.map((slot) => {\n          if (slot === \"action\") {\n            return (\n              <li key=\"action\" className=\"flex flex-1 items-center justify-center\">\n                <motion.button\n                  type=\"button\"\n                  aria-label={centerAction?.label}\n                  onClick={centerAction?.onClick}\n                  whileTap={{ scale: 0.9 }}\n                  className=\"flex cursor-pointer items-center justify-center rounded-full border-none outline-none focus-visible:ring-2 focus-visible:ring-offset-2\"\n                  style={{ width: s.action, height: s.action, marginTop: floating ? 0 : -s.action / 3, background: p.action, color: p.actionFg, boxShadow: `0 6px 18px ${theme === \"dark\" ? \"rgba(0,0,0,0.5)\" : \"rgba(10,10,10,0.25)\"}`, [\"--tw-ring-color\" as string]: p.focus, [\"--tw-ring-offset-color\" as string]: p.ring }}\n                >\n                  <span style={{ width: s.icon, height: s.icon }}>{centerAction?.icon ?? svg(\"M12 5v14M5 12h14\")}</span>\n                </motion.button>\n              </li>\n            );\n          }\n          const item = slot;\n          const active = item.id === current;\n          const showLabel = labels === \"always\" || (labels === \"active\" && active);\n          const Tag = item.href ? \"a\" : \"button\";\n          return (\n            <li key={item.id} className=\"relative flex flex-1\">\n              <Tag\n                data-tab\n                {...(item.href ? { href: item.href } : { type: \"button\" as const })}\n                aria-current={active ? \"page\" : undefined}\n                aria-label={labels === \"none\" ? item.label : undefined}\n                onClick={() => select(item.id)}\n                className=\"relative flex flex-1 cursor-pointer flex-col items-center justify-center border-none bg-transparent no-underline outline-none focus-visible:ring-2 focus-visible:ring-inset\"\n                style={{ gap: 3, borderRadius: floating ? s.height : 14, color: active ? p.text : p.muted, transition: \"color 0.2s ease\", [\"--tw-ring-color\" as string]: p.focus }}\n              >\n                {active && (\n                  <motion.span\n                    layoutId={reduce ? undefined : `${uid}-pill`}\n                    className=\"absolute\"\n                    style={{ inset: floating ? 0 : \"6px 4px\", borderRadius: floating ? s.height : 14, background: p.pill }}\n                    transition={{ type: \"spring\", stiffness: 480, damping: 36 }}\n                  />\n                )}\n                <motion.span\n                  key={active ? `${item.id}-on` : item.id}\n                  className=\"relative\"\n                  style={{ width: s.icon, height: s.icon }}\n                  initial={active && !reduce ? { scale: 0.7, y: 2 } : false}\n                  animate={{ scale: 1, y: 0 }}\n                  transition={{ type: \"spring\", stiffness: 520, damping: 18 }}\n                >\n                  {item.icon}\n                  <AnimatePresence>\n                    {item.badge ? (\n                      <motion.span\n                        key=\"badge\"\n                        initial={{ scale: 0 }}\n                        animate={{ scale: 1 }}\n                        exit={{ scale: 0 }}\n                        className=\"absolute flex items-center justify-center font-semibold tabular-nums\"\n                        style={\n                          item.badge === true\n                            ? { top: -1, right: -2, width: 8, height: 8, borderRadius: 4, background: p.badge, boxShadow: `0 0 0 2px ${p.ring}` }\n                            : { top: -6, right: -10, minWidth: 17, height: 17, padding: \"0 4px\", borderRadius: 9, background: p.badge, color: p.badgeFg, fontSize: 10, lineHeight: 1, boxShadow: `0 0 0 2px ${p.ring}` }\n                        }\n                      >\n                        {item.badge === true ? null : Number(item.badge) > 99 ? \"99+\" : item.badge}\n                      </motion.span>\n                    ) : null}\n                  </AnimatePresence>\n                </motion.span>\n                <AnimatePresence initial={false}>\n                  {showLabel && (\n                    <motion.span\n                      key=\"label\"\n                      initial={{ opacity: 0, height: 0 }}\n                      animate={{ opacity: 1, height: \"auto\" }}\n                      exit={{ opacity: 0, height: 0 }}\n                      transition={{ duration: 0.18 }}\n                      className=\"relative font-semibold\"\n                      style={{ fontSize: s.font, lineHeight: 1.2, letterSpacing: \"0.01em\" }}\n                    >\n                      {item.label}\n                    </motion.span>\n                  )}\n                </AnimatePresence>\n                {item.badge && typeof item.badge === \"number\" ? <span className=\"sr-only\">, {item.badge} new</span> : null}\n              </Tag>\n            </li>\n          );\n        })}\n      </ul>\n    </nav>\n  );\n}\n\nexport default MobileTabBar;\n",
      "type": "registry:component"
    }
  ],
  "type": "registry:component"
}