{
  "component": {
    "id": "segmented-control",
    "name": "Segmented control",
    "tier": "free",
    "exampleId": "segmented-control",
    "access": "free",
    "requiresAuthorization": false
  },
  "source": {
    "demoModule": "src/core-demos.tsx",
    "exportName": "SegmentDemo",
    "sha256": "45573c4c14fe92971eaeed797aa2352489c113a7e50f0f57d950caee5f616dff",
    "helperImports": [],
    "directComponentImports": [
      "segmented-control"
    ],
    "sampleBoundary": "Existing local demo fixture with fictional data and callbacks. No live service, customer data, access key, or Pro source is included."
  },
  "install": {
    "command": "npx shadcn@latest add https://tidalui.com/r/segmented-control.json",
    "registryUrl": "https://tidalui.com/r/segmented-control.json",
    "access": "free",
    "sourceDelivery": "public-registry",
    "requiresAuthorization": false,
    "tokenSource": "none",
    "cli": {
      "package": "shadcn",
      "requested": "latest"
    }
  },
  "installPlan": [
    {
      "order": 1,
      "kind": "primary",
      "dependency": "https://tidalui.com/r/segmented-control.json",
      "purpose": "component",
      "command": "npx shadcn@latest add https://tidalui.com/r/segmented-control.json",
      "registryUrl": "https://tidalui.com/r/segmented-control.json",
      "access": "free",
      "sourceDelivery": "public-registry",
      "requiresAuthorization": false
    }
  ],
  "imports": {
    "componentPath": "components/ui/segmented-control.tsx",
    "exports": [
      "TidalSegmentedControl"
    ],
    "stylesheets": [
      "components/ui/tidal.css",
      "components/ui/segmented-control.css"
    ],
    "scopeClass": "tidal-scope"
  },
  "dependencies": {
    "npm": [],
    "registry": [],
    "additionalRegistry": [],
    "installClosure": [
      "segmented-control"
    ],
    "css": [
      "components/ui/tidal.css",
      "components/ui/segmented-control.css"
    ],
    "demoCss": [],
    "consumerOwned": [
      "react",
      "react-dom"
    ]
  },
  "files": {
    "sourceFile": "/examples/segmented-control.tsx",
    "demoStyles": [],
    "inlinedDemoStyles": [
      "src/demo-styles.css"
    ],
    "assets": []
  },
  "example": {
    "language": "tsx",
    "source": "import \"./components/ui/tidal.css\";\n\nimport { useState, useId, type PointerEvent } from \"react\";\n\nimport { TidalSegmentedControl } from \"./components/ui/segmented-control\";\n\nimport \"./components/ui/segmented-control.css\";\n\n\n\nconst tidalExampleStyles = \".segment-specimen{background:var(--t-surface);border:1px solid var(--t-border);border-radius:var(--t-radius-card);padding:21px;width:100%;max-width:315px;box-shadow:0 10px 20px -12px #00000026,0 1px 2px #00000008}.demo-eyebrow{font-size:11px;letter-spacing:1px;color:var(--t-muted);font-weight:500;margin:0 0 13px}.segment-stat{display:flex;align-items:center;justify-content:space-between;margin:20px 0 14px;gap:10px}.segment-stat strong{font-size:33px;font-weight:500;letter-spacing:-1.5px;line-height:1.1;font-variant-numeric:tabular-nums;animation:tidal-stat-in 220ms var(--t-ease-out)}.segment-stat>span{font-size:11px;padding:4px 7px;background:var(--t-wash);border-radius:5px;color:var(--t-accent)}.segment-bars{display:flex;align-items:flex-end;gap:7px;height:40px;margin-bottom:18px;overflow:hidden}.segment-bars span{flex:1;background:var(--t-border);border-radius:3px 3px 0 0;transition:height 320ms var(--t-ease-out)}.segment-bars span:nth-last-child(-n+3){background:var(--t-accent);opacity:.65}.segment-specimen .tidal-segments button{font-size:11px;padding:0 5px}\\n\\n@keyframes tidal-stat-in{from{opacity:0;transform:translateY(4px)}to{opacity:1;transform:none}}\\n.workspace-demo-sr{position:absolute;width:1px;height:1px;padding:0;margin:-1px;overflow:hidden;clip:rect(0,0,0,0);white-space:nowrap;border:0}\\n.segment-chart{position:relative;padding-top:26px}.segment-chart .segment-bars{height:60px;margin:0 0 18px;padding:6px 0;cursor:crosshair;touch-action:pan-y;min-height:44px}.segment-chart .segment-bars>span{flex:1;min-width:0;transition:height 420ms var(--t-ease-out),opacity 180ms,background 180ms}.segment-chart .segment-bars:has([data-selected=true])>span{opacity:.35}.segment-chart .segment-bars>span[data-selected=true]{opacity:1;background:var(--t-ink)}.segment-value{position:absolute;inset:0 0 auto;display:flex;align-items:center;justify-content:space-between;gap:12px;font-size:11px;color:var(--t-muted);pointer-events:none}.segment-value strong{color:var(--t-ink);font-weight:550;font-variant-numeric:tabular-nums}.segment-chart .segment-bars:focus-visible{outline-offset:3px}\";\n\nconst segmentPeriods = {\n  week: {\n    total: 8240,\n    growth: \"+8.2%\",\n    weights: [26, 37, 29, 41, 46, 40, 56],\n    labels: [\n      \"Mon, Oct 5\",\n      \"Tue, Oct 6\",\n      \"Wed, Oct 7\",\n      \"Thu, Oct 8\",\n      \"Fri, Oct 9\",\n      \"Sat, Oct 10\",\n      \"Sun, Oct 11\",\n    ],\n  },\n  month: {\n    total: 32480,\n    growth: \"+14.8%\",\n    weights: [18, 25, 32, 23, 40, 36, 51, 64],\n    labels: [\n      \"Oct 1–4\",\n      \"Oct 5–8\",\n      \"Oct 9–12\",\n      \"Oct 13–16\",\n      \"Oct 17–20\",\n      \"Oct 21–24\",\n      \"Oct 25–28\",\n      \"Oct 29–31\",\n    ],\n  },\n  year: {\n    total: 384920,\n    growth: \"+28.6%\",\n    weights: [14, 23, 26, 38, 33, 48, 62, 76, 65, 70, 73, 81],\n    labels: [\n      \"January\",\n      \"February\",\n      \"March\",\n      \"April\",\n      \"May\",\n      \"June\",\n      \"July\",\n      \"August\",\n      \"September\",\n      \"October\",\n      \"November\",\n      \"December\",\n    ],\n  },\n};\n\nexport function SegmentDemo() {\n  const [period, setPeriod] = useState<keyof typeof segmentPeriods>(\"month\");\n  const [inspected, setInspected] = useState<number | null>(null);\n  const [focused, setFocused] = useState(false);\n  const helpId = useId();\n  const data = segmentPeriods[period];\n  const weightTotal = data.weights.reduce((a, b) => a + b, 0);\n  const values = data.weights.map((weight) =>\n    Math.floor((weight / weightTotal) * data.total),\n  );\n  values[values.length - 1] += data.total - values.reduce((a, b) => a + b, 0);\n  const active =\n    inspected === null ? null : Math.min(inspected, values.length - 1);\n  const money = (value: number) => \"$\" + value.toLocaleString(\"en-US\");\n  const selected = active ?? values.length - 1;\n  function inspect(event: PointerEvent<HTMLDivElement>) {\n    const bounds = event.currentTarget.getBoundingClientRect();\n    setInspected(\n      Math.max(\n        0,\n        Math.min(\n          values.length - 1,\n          Math.floor(\n            ((event.clientX - bounds.left) / bounds.width) * values.length,\n          ),\n        ),\n      ),\n    );\n  }\n  return (\n    <div className=\"segment-specimen\">\n      <p className=\"demo-eyebrow\">REVENUE OVER TIME</p>\n      <div className=\"segment-stat\">\n        <strong key={period}>{money(data.total)}</strong>\n        <span>{data.growth}</span>\n      </div>\n      <div className=\"segment-chart\">\n        {active !== null ? (\n          <div className=\"segment-value\" aria-hidden=\"true\">\n            <span>{data.labels[active]}</span>\n            <strong>{money(values[active])}</strong>\n          </div>\n        ) : null}\n        <div\n          className=\"segment-bars\"\n          role=\"slider\"\n          tabIndex={0}\n          aria-label=\"Inspect revenue bars\"\n          aria-orientation=\"horizontal\"\n          aria-valuemin={0}\n          aria-valuemax={values.length - 1}\n          aria-valuenow={selected}\n          aria-valuetext={`${data.labels[selected]}: ${money(values[selected])}`}\n          aria-describedby={helpId}\n          onPointerMove={(event) => {\n            if (event.pointerType !== \"touch\") inspect(event);\n          }}\n          onPointerDown={(event) => {\n            event.currentTarget.focus({ preventScroll: true });\n            inspect(event);\n          }}\n          onPointerLeave={() => {\n            if (!focused) setInspected(null);\n          }}\n          onFocus={() => {\n            setFocused(true);\n            setInspected((current) => current ?? values.length - 1);\n          }}\n          onBlur={() => {\n            setFocused(false);\n            setInspected(null);\n          }}\n          onKeyDown={(event) => {\n            const step =\n              event.key === \"ArrowRight\" || event.key === \"ArrowUp\"\n                ? 1\n                : event.key === \"ArrowLeft\" || event.key === \"ArrowDown\"\n                  ? -1\n                  : 0;\n            if (!step && event.key !== \"Home\" && event.key !== \"End\") return;\n            event.preventDefault();\n            setInspected(\n              event.key === \"Home\"\n                ? 0\n                : event.key === \"End\"\n                  ? values.length - 1\n                  : Math.max(0, Math.min(values.length - 1, selected + step)),\n            );\n          }}\n        >\n          {values.map((value, index) => (\n            <span\n              key={`${period}-${index}`}\n              data-selected={active === index}\n              data-label={data.labels[index]}\n              data-value={value}\n              aria-hidden=\"true\"\n              style={{ height: `${10 + (value / Math.max(...values)) * 38}px` }}\n            />\n          ))}\n        </div>\n      </div>\n      <span id={helpId} className=\"workspace-demo-sr\">\n        Hover or tap a bar to inspect its revenue. Use arrow keys, Home or End\n        when focused. Sample data.\n      </span>\n      <TidalSegmentedControl\n        label=\"Revenue period\"\n        value={period}\n        onValueChange={(value) => {\n          setPeriod(value as keyof typeof segmentPeriods);\n          setInspected(null);\n        }}\n        options={[\n          { value: \"week\", label: \"Week\" },\n          { value: \"month\", label: \"Month\" },\n          { value: \"year\", label: \"Year\" },\n        ]}\n      />\n    </div>\n  );\n}\n\nexport default function AgentExample() {\n  return (\n    <div className=\"tidal-scope\" data-theme=\"light\" dir=\"ltr\">\n      <style>{tidalExampleStyles}</style>\n      <SegmentDemo />\n    </div>\n  );\n}\n",
    "sourceFile": "/examples/segmented-control.tsx",
    "fixtureData": "Existing demo fixture data only; replace with consumer-owned data before production use."
  },
  "controlledState": [
    {
      "prop": "value",
      "type": "inferred-from-existing-demo",
      "initial": "\"month\"",
      "setter": "setPeriod",
      "proposalCanBeRejected": false
    }
  ],
  "events": [
    {
      "name": "onBlur",
      "nativeType": "React synthetic event or native callback",
      "callerFirst": false,
      "preventable": false,
      "observedResult": "The existing demo callback remains the source of truth; this example does not call a live service."
    },
    {
      "name": "onFocus",
      "nativeType": "React synthetic event or native callback",
      "callerFirst": false,
      "preventable": false,
      "observedResult": "The existing demo callback remains the source of truth; this example does not call a live service."
    },
    {
      "name": "onKeyDown",
      "nativeType": "React synthetic event or native callback",
      "callerFirst": false,
      "preventable": false,
      "observedResult": "The existing demo callback remains the source of truth; this example does not call a live service."
    },
    {
      "name": "onPointerDown",
      "nativeType": "component callback",
      "callerFirst": false,
      "preventable": false,
      "observedResult": "The existing demo callback remains the source of truth; this example does not call a live service."
    },
    {
      "name": "onPointerLeave",
      "nativeType": "component callback",
      "callerFirst": false,
      "preventable": false,
      "observedResult": "The existing demo callback remains the source of truth; this example does not call a live service."
    },
    {
      "name": "onPointerMove",
      "nativeType": "component callback",
      "callerFirst": false,
      "preventable": false,
      "observedResult": "The existing demo callback remains the source of truth; this example does not call a live service."
    },
    {
      "name": "onValueChange",
      "nativeType": "component callback",
      "callerFirst": false,
      "preventable": false,
      "observedResult": "The existing demo callback remains the source of truth; this example does not call a live service."
    }
  ],
  "nativeForm": {
    "participates": true,
    "names": [],
    "expectedFormData": {},
    "submitBehavior": "The existing demo's native form callback receives the submit event.",
    "resetBehavior": "Native reset behavior remains available where the demo renders a resettable control.",
    "disabledBehavior": "Disabled controls remain excluded from successful native form submission.",
    "readOnlyBehavior": "Read-only controls retain their value and remain inspectable by the consumer."
  },
  "accessibility": {
    "labelSource": "Existing demo label or ARIA prop",
    "semantics": "Preserve the component's native element and the semantics demonstrated by the source fixture.",
    "keyboard": [
      "Tab and Shift+Tab",
      "Enter or Space for native activation",
      "Arrow keys where the component exposes a composite control"
    ],
    "focusReturn": "Preserve browser focus order and visible focus.",
    "errorAnnouncement": "No error announcement path is present in this demo; the consumer owns validation messaging.",
    "reducedMotion": "Verify prefers-reduced-motion with the existing component transition path.",
    "forcedColors": "Verify visible borders, text, and focus in forced-colors mode."
  },
  "responsive": {
    "widths": [
      320,
      390,
      768,
      1260
    ],
    "shortViewport": "Check the example at a 300px viewport height with keyboard or portal content visible.",
    "overflow": "The page should not gain horizontal overflow; component-local scrolling must remain intentional.",
    "touchTargetMinPx": 44,
    "coarseInputFontPx": 16
  },
  "errors": [
    {
      "fixture": "No error fixture is exposed by the existing demo; inject a consumer-owned failure state before production use.",
      "visibleResult": "The consumer-visible result must remain explicit and must not be replaced by a silent console error.",
      "focusResult": "Focus must remain on the triggering control or move to the announced error according to the native pattern.",
      "ownership": "Consumer-owned sample state only; no network request or customer data is used."
    }
  ],
  "verification": {
    "commands": [
      "npx tsc --noEmit",
      "npx vite build"
    ],
    "lockfile": "Use the consumer project's committed lockfile.",
    "browser": [
      "Chromium 1260x800",
      "Chromium 390x844",
      "Keyboard and reduced-motion pass"
    ]
  },
  "validation": {
    "consumerFixture": {
      "tsc": "pass",
      "viteBuild": "pass",
      "resourceModel": "Generated usage plus only the component files and CSS delivered by the primary item and listed registry dependencies."
    },
    "registryArtifact": "present-local"
  },
  "exceptions": []
}
