{"$schema":"https://ui.shadcn.com/schema/registry-item.json","name":"vertical-tabs-with-settings-panels","type":"registry:component","title":"Vertical Tabs With Settings Panels","description":"","dependencies":[],"files":[{"path":"components/we-inc/vertical-tabs-with-settings-panels.tsx","type":"registry:component","content":"import { useRef, useState, type KeyboardEvent } from \"react\";\n\n// Settings sections. Each panel lists a few rows of label and value.\nconst sections = [\n  { id: \"profile\", label: \"Profile\", hint: \"Name, photo and bio\", rows: [[\"Display name\", \"Rosa Achterberg\"], [\"Studio\", \"Achterberg Ceramics\"], [\"Time zone\", \"Amsterdam (UTC+1)\"]] },\n  { id: \"notifications\", label: \"Notifications\", hint: \"Email and push\", rows: [[\"New orders\", \"Email and push\"], [\"Weekly summary\", \"Mondays at 8:00\"], [\"Product tips\", \"Off\"]] },\n  { id: \"billing\", label: \"Billing\", hint: \"Plan and invoices\", rows: [[\"Plan\", \"Maker, $19 a month\"], [\"Next invoice\", \"1 December\"], [\"Card\", \"Visa ending 4421\"]] },\n  { id: \"security\", label: \"Security\", hint: \"Password and sign-in\", rows: [[\"Password\", \"Changed 3 months ago\"], [\"Two-step sign-in\", \"On, authenticator app\"], [\"Sessions\", \"2 devices\"]] },\n];\n\nexport default function VerticalTabsWithSettingsPanels() {\n  const [active, setActive] = useState(0);\n  const refs = useRef<(HTMLButtonElement | null)[]>([]);\n\n  const onKey = (e: KeyboardEvent<HTMLDivElement>) => {\n    const last = sections.length - 1;\n    const down = active === last ? 0 : active + 1;\n    const up = active === 0 ? last : active - 1;\n    // Up and Down follow the vertical layout; Left and Right also work for the phone row.\n    const next = { ArrowDown: down, ArrowRight: down, ArrowUp: up, ArrowLeft: up, Home: 0, End: last }[e.key];\n    if (next === undefined) return;\n    e.preventDefault();\n    setActive(next);\n    refs.current[next]?.focus();\n  };\n\n  return (\n    <div className=\"bg-violet-50 px-4 py-12 sm:px-8\">\n      <div className=\"mx-auto flex max-w-3xl flex-col gap-6 rounded-2xl bg-white p-4 ring-1 ring-violet-100 sm:flex-row sm:p-6\">\n        <div role=\"tablist\" aria-label=\"Account settings\" aria-orientation=\"vertical\" onKeyDown={onKey} className=\"flex shrink-0 gap-1 overflow-x-auto sm:w-56 sm:flex-col\">\n          {sections.map((s, i) => (\n            <button\n              key={s.id}\n              ref={(el) => { refs.current[i] = el; }}\n              id={`vts-tab-${s.id}`}\n              role=\"tab\"\n              type=\"button\"\n              aria-selected={i === active}\n              aria-controls={`vts-panel-${s.id}`}\n              tabIndex={i === active ? 0 : -1}\n              onClick={() => setActive(i)}\n              className={`shrink-0 rounded-xl px-4 py-2.5 text-left focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-violet-500 ${i === active ? \"bg-violet-600 text-white\" : \"text-slate-700 hover:bg-violet-50\"}`}\n            >\n              <span className=\"block text-sm font-semibold\">{s.label}</span>\n              <span className={`hidden text-xs sm:block ${i === active ? \"text-violet-100\" : \"text-slate-600\"}`}>{s.hint}</span>\n            </button>\n          ))}\n        </div>\n        {sections.map((s, i) => (\n          <div key={s.id} id={`vts-panel-${s.id}`} role=\"tabpanel\" aria-labelledby={`vts-tab-${s.id}`} tabIndex={0} hidden={i !== active} className=\"min-w-0 flex-1 rounded-xl focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-violet-500\">\n            <h3 className=\"text-lg font-semibold text-slate-900\">{s.label}</h3>\n            <dl className=\"mt-4 divide-y divide-slate-100 border-y border-slate-100\">\n              {s.rows.map(([k, v]) => (\n                <div key={k} className=\"flex flex-wrap items-center justify-between gap-2 py-3.5\">\n                  <dt className=\"text-sm text-slate-600\">{k}</dt>\n                  <dd className=\"text-sm font-medium text-slate-900\">{v}</dd>\n                </div>\n              ))}\n            </dl>\n            <button type=\"button\" className=\"mt-5 h-10 rounded-lg border border-slate-300 px-4 text-sm font-medium text-slate-800 hover:bg-slate-50 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-violet-500\">Edit {s.label.toLowerCase()}</button>\n          </div>\n        ))}\n      </div>\n    </div>\n  );\n}\n"}]}
