{
  "schemaVersion": 1,
  "target": "react",
  "name": "radio-group",
  "version": "0.1.1",
  "category": "forms",
  "title": "Radio Group",
  "description": "A single-choice group as plain radios or as selectable option cards with an icon, description, and price.",
  "tags": [
    "form",
    "radio",
    "cards",
    "choice",
    "base-ui"
  ],
  "requires": {
    "projectTypes": [
      "next",
      "vite-react"
    ],
    "styling": "tailwind-v4"
  },
  "npmDependencies": {
    "@base-ui/react": "^1.9.0"
  },
  "registryDependencies": [],
  "docsPath": "/components/radio-group",
  "props": [
    {
      "name": "variant",
      "type": "\"plain\" | \"cards\"",
      "default": "\"plain\"",
      "description": "Plain radios with labels, or a card per option."
    },
    {
      "name": "value / defaultValue",
      "type": "string",
      "description": "The selected item's value."
    },
    {
      "name": "onValueChange",
      "type": "(value) => void",
      "description": "Called when the selection changes."
    },
    {
      "name": "label / description",
      "type": "ReactNode",
      "description": "Names and describes the group."
    },
    {
      "name": "label (RadioGroupItem)",
      "type": "ReactNode",
      "description": "The option's name; required."
    },
    {
      "name": "description (RadioGroupItem)",
      "type": "ReactNode",
      "description": "Secondary line, linked with aria-describedby."
    },
    {
      "name": "icon / meta (RadioGroupItem)",
      "type": "ReactNode",
      "description": "Cards only: a 16px icon tile at the start and a short value such as a price at the end."
    },
    {
      "name": "disabled",
      "type": "boolean",
      "default": "false",
      "description": "On the group or one item."
    }
  ],
  "accessibility": [
    "Base UI renders role=\"radiogroup\" with role=\"radio\" items and roving focus: arrow keys move and select, Tab leaves the group.",
    "Each radio is named by its label through aria-labelledby, and its description is linked with aria-describedby, so a card's long text is not read as its name.",
    "In the cards variant the whole card is the click target and draws the focus ring when the radio inside has keyboard focus.",
    "The selected card thickens its border to 2px, so selection does not depend on color alone.",
    "The dot scales in only with motion allowed."
  ],
  "states": [
    "unselected",
    "selected",
    "focus-visible",
    "disabled"
  ],
  "files": [
    {
      "path": "ui/radio-group.tsx",
      "content": "\"use client\";\n\nimport { Radio as BaseRadio } from \"@base-ui/react/radio\";\nimport { RadioGroup as BaseRadioGroup } from \"@base-ui/react/radio-group\";\nimport { createContext, type ReactNode, useContext, useId } from \"react\";\n\ntype ClassName<State> = string | ((state: State) => string | undefined) | undefined;\n\nfunction cx(...classes: (string | false | null | undefined)[]) {\n  return classes.filter(Boolean).join(\" \");\n}\n\n/** Prepends base classes while keeping Base UI's state-function form of className working. */\nfunction withBase<State>(base: string, className: ClassName<State>) {\n  return typeof className === \"function\" ? (state: State) => cx(base, className(state)) : cx(base, className);\n}\n\nexport type RadioGroupVariant = \"plain\" | \"cards\";\n\nconst VariantContext = createContext<RadioGroupVariant>(\"plain\");\n\nexport interface RadioGroupProps<Value = string> extends BaseRadioGroup.Props<Value> {\n  /** `plain` lists radios with labels; `cards` turns each option into a selectable card. */\n  variant?: RadioGroupVariant;\n  /** Names the group. Linked with `aria-labelledby`. */\n  label?: ReactNode;\n  /** A sentence under the label about the choice. */\n  description?: ReactNode;\n}\n\n/**\n * One choice from a set. Arrow keys move the selection between options and Tab leaves the group,\n * as in a native radio group. Set `defaultValue` (or `value` + `onValueChange`) to an item's `value`.\n */\nexport function RadioGroup<Value = string>({\n  variant = \"plain\",\n  label,\n  description,\n  className,\n  children,\n  ...props\n}: RadioGroupProps<Value>) {\n  const id = useId();\n  const labelId = `${id}-label`;\n  const descriptionId = `${id}-description`;\n  return (\n    <VariantContext.Provider value={variant}>\n      <BaseRadioGroup<Value>\n        data-variant={variant}\n        aria-labelledby={label != null ? labelId : undefined}\n        aria-describedby={description != null ? descriptionId : undefined}\n        className={withBase(cx(\"grid content-start\", variant === \"cards\" ? \"gap-2\" : \"gap-3\"), className)}\n        {...props}\n      >\n        {label != null || description != null ? (\n          <div className={cx(\"grid gap-0.5\", variant === \"cards\" && \"mb-1\")}>\n            {label != null ? (\n              <div id={labelId} className=\"text-sm leading-5 font-medium text-zinc-950 dark:text-white\">\n                {label}\n              </div>\n            ) : null}\n            {description != null ? (\n              <p id={descriptionId} className=\"text-sm leading-5 text-zinc-500 dark:text-zinc-400\">\n                {description}\n              </p>\n            ) : null}\n          </div>\n        ) : null}\n        {children}\n      </BaseRadioGroup>\n    </VariantContext.Provider>\n  );\n}\n\nexport interface RadioGroupItemProps<Value = string> extends Omit<BaseRadio.Root.Props<Value>, \"children\"> {\n  /** The option's name. */\n  label: ReactNode;\n  /** A secondary line, linked with `aria-describedby` so it is read after the name. */\n  description?: ReactNode;\n  /** Cards only: a 16px icon shown in a small tile at the start of the card. */\n  icon?: ReactNode;\n  /** Cards only: a short value at the end of the card, such as a price or a limit. */\n  meta?: ReactNode;\n  /** Classes for the wrapping label (the card in the cards variant). `className` styles the radio. */\n  containerClassName?: string;\n}\n\nconst radio = cx(\n  \"group/radio relative inline-flex size-4 shrink-0 cursor-pointer items-center justify-center rounded-full border outline-none\",\n  \"after:absolute after:-inset-2 after:content-['']\",\n  \"border-zinc-950/25 bg-white shadow-[0_1px_1px_rgb(0_0_0/0.04)] hover:border-zinc-950/40\",\n  \"dark:border-white/25 dark:bg-black dark:shadow-none dark:hover:border-white/40\",\n  \"data-[checked]:border-zinc-950 data-[checked]:bg-zinc-950 dark:data-[checked]:border-white dark:data-[checked]:bg-white\",\n  \"data-[invalid]:border-red-500 dark:data-[invalid]:border-red-400\",\n  \"transition-[background-color,border-color] duration-150 ease-out motion-reduce:transition-none\",\n  \"data-[disabled]:cursor-not-allowed\",\n);\n\n/** One option. In the cards variant the whole card is the click target and shows the focus ring. */\nexport function RadioGroupItem<Value = string>({\n  label,\n  description,\n  icon,\n  meta,\n  containerClassName,\n  className,\n  \"aria-describedby\": describedBy,\n  ...props\n}: RadioGroupItemProps<Value>) {\n  const variant = useContext(VariantContext);\n  const id = useId();\n  const labelId = `${id}-label`;\n  const descriptionId = `${id}-description`;\n  const cards = variant === \"cards\";\n\n  const control = (\n    <BaseRadio.Root<Value>\n      aria-labelledby={labelId}\n      aria-describedby={cx(description != null && descriptionId, describedBy) || undefined}\n      className={withBase(\n        cx(\n          radio,\n          cards ? \"focus-visible:outline-none\" : \"focus-visible:outline-2 focus-visible:outline-solid focus-visible:outline-offset-2 focus-visible:outline-sky-500\",\n        ),\n        className,\n      )}\n      {...props}\n    >\n      <BaseRadio.Indicator\n        keepMounted\n        className={cx(\n          \"size-1.5 rounded-full bg-white dark:bg-black\",\n          \"scale-50 opacity-0 transition-[scale,opacity] duration-100 ease-out motion-reduce:transition-none\",\n          \"data-[checked]:scale-100 data-[checked]:opacity-100 data-[checked]:duration-200 data-[checked]:ease-[cubic-bezier(0.22,1,0.36,1)]\",\n        )}\n      />\n    </BaseRadio.Root>\n  );\n\n  if (!cards) {\n    return (\n      <label\n        className={cx(\n          \"group/item grid cursor-pointer grid-cols-[auto_1fr] items-start gap-x-2.5 gap-y-0.5 has-[[data-disabled]]:cursor-not-allowed\",\n          containerClassName,\n        )}\n      >\n        <span className=\"flex h-5 items-center\">{control}</span>\n        <span id={labelId} className=\"text-sm leading-5 text-zinc-950 select-none group-has-[[data-disabled]]/item:opacity-50 dark:text-white\">\n          {label}\n        </span>\n        {description != null ? (\n          <span\n            id={descriptionId}\n            className=\"col-start-2 text-sm leading-5 text-zinc-500 group-has-[[data-disabled]]/item:opacity-50 dark:text-zinc-400\"\n          >\n            {description}\n          </span>\n        ) : null}\n      </label>\n    );\n  }\n\n  return (\n    <label\n      className={cx(\n        \"group/card relative flex cursor-pointer items-start gap-3 rounded-xl border p-3.5 select-none\",\n        \"border-zinc-950/10 bg-white shadow-[0_1px_2px_rgb(0_0_0/0.04)] hover:border-zinc-950/20\",\n        \"dark:border-white/10 dark:bg-black dark:shadow-[inset_0_1px_0_rgb(255_255_255/0.06)] dark:hover:border-white/20\",\n        // Selected: the border thickens to 2px (an inset ring, so nothing shifts) and the card takes the selected tint.\n        \"has-[[data-checked]]:border-zinc-950 has-[[data-checked]]:bg-zinc-950/[0.02] has-[[data-checked]]:shadow-[inset_0_0_0_1px_rgb(9_9_11)]\",\n        \"dark:has-[[data-checked]]:border-white dark:has-[[data-checked]]:bg-white/[0.04] dark:has-[[data-checked]]:shadow-[inset_0_0_0_1px_rgb(255_255_255)]\",\n        \"transition-[background-color,border-color,box-shadow] duration-150 ease-out motion-reduce:transition-none\",\n        \"has-[:focus-visible]:outline-2 has-[:focus-visible]:outline-solid has-[:focus-visible]:outline-offset-2 has-[:focus-visible]:outline-sky-500\",\n        \"has-[[data-disabled]]:cursor-not-allowed has-[[data-disabled]]:opacity-50 has-[[data-disabled]]:hover:border-zinc-950/10 dark:has-[[data-disabled]]:hover:border-white/10\",\n        containerClassName,\n      )}\n    >\n      {icon != null ? (\n        <span\n          aria-hidden=\"true\"\n          className={cx(\n            \"flex size-8 shrink-0 items-center justify-center rounded-lg border border-zinc-950/10 text-zinc-600 dark:border-white/10 dark:text-zinc-400\",\n            \"transition-colors duration-150 ease-out motion-reduce:transition-none\",\n            \"group-has-[[data-checked]]/card:text-zinc-950 dark:group-has-[[data-checked]]/card:text-white [&_svg]:size-4\",\n          )}\n        >\n          {icon}\n        </span>\n      ) : null}\n      <span className=\"grid min-w-0 flex-1 gap-0.5\">\n        <span id={labelId} className=\"text-sm leading-5 font-medium text-zinc-950 dark:text-white\">\n          {label}\n        </span>\n        {description != null ? (\n          <span id={descriptionId} className=\"text-sm leading-5 text-zinc-500 dark:text-zinc-400\">\n            {description}\n          </span>\n        ) : null}\n      </span>\n      {meta != null ? (\n        <span className=\"shrink-0 text-sm leading-5 text-zinc-600 tabular-nums dark:text-zinc-400\">{meta}</span>\n      ) : null}\n      <span className=\"flex h-5 shrink-0 items-center\">{control}</span>\n    </label>\n  );\n}\n"
    }
  ],
  "example": {
    "content": "import { RadioGroup, RadioGroupItem } from \"@/components/shaken/ui/radio-group\";\n\nfunction CpuIcon() {\n  return (\n    <svg viewBox=\"0 0 16 16\" fill=\"none\" stroke=\"currentColor\" strokeWidth=\"1.5\" strokeLinecap=\"round\">\n      <rect x=\"4\" y=\"4\" width=\"8\" height=\"8\" rx=\"1.5\" />\n      <path d=\"M6.5 1.75v2M9.5 1.75v2M6.5 12.25v2M9.5 12.25v2M1.75 6.5h2M1.75 9.5h2M12.25 6.5h2M12.25 9.5h2\" />\n    </svg>\n  );\n}\n\nfunction BoltIcon() {\n  return (\n    <svg viewBox=\"0 0 16 16\" fill=\"none\" stroke=\"currentColor\" strokeWidth=\"1.5\" strokeLinejoin=\"round\">\n      <path d=\"M8.75 1.75L3.5 9h4l-.75 5.25L12.5 7h-4l.25-5.25z\" />\n    </svg>\n  );\n}\n\nfunction LayersIcon() {\n  return (\n    <svg viewBox=\"0 0 16 16\" fill=\"none\" stroke=\"currentColor\" strokeWidth=\"1.5\" strokeLinejoin=\"round\">\n      <path d=\"M8 2l6 3.25-6 3.25-6-3.25L8 2z\" />\n      <path d=\"M2 8.25l6 3.25 6-3.25M2 11l6 3.25L14 11\" />\n    </svg>\n  );\n}\n\nexport default function RadioGroupExample() {\n  return (\n    <div className=\"grid w-full max-w-md gap-8\">\n      <RadioGroup variant=\"cards\" label=\"Runner\" defaultValue=\"standard\" name=\"runner\">\n        <RadioGroupItem value=\"standard\" icon={<CpuIcon />} label=\"Standard\" description=\"2 vCPU, 4 GB. Fine for most agents.\" meta=\"$0.04/min\" />\n        <RadioGroupItem value=\"burst\" icon={<BoltIcon />} label=\"Burst\" description=\"8 vCPU, 16 GB for builds and test runs.\" meta=\"$0.16/min\" />\n        <RadioGroupItem value=\"dedicated\" icon={<LayersIcon />} label=\"Dedicated\" description=\"Reserved capacity with a fixed IP.\" meta=\"Contact us\" disabled />\n      </RadioGroup>\n\n      <RadioGroup label=\"When a tool call needs approval\" defaultValue=\"ask\" name=\"approval\">\n        <RadioGroupItem value=\"ask\" label=\"Ask me every time\" />\n        <RadioGroupItem value=\"trusted\" label=\"Allow tools I marked as trusted\" description=\"Everything else still waits for a person.\" />\n        <RadioGroupItem value=\"never\" label=\"Never pause the run\" />\n      </RadioGroup>\n    </div>\n  );\n}\n"
  }
}
