{
  "$schema": "https://ui.shadcn.com/schema/registry-item.json",
  "name": "radio-group",
  "title": "Radio Group",
  "description": "One choice from a short list with every option in view, as dots, selectable cards, joined buttons or rows, with arrow keys built in.",
  "dependencies": [
    "radix-ui",
    "lucide-react",
    "motion"
  ],
  "registryDependencies": [
    "utils",
    "https://miseui.junsu4621.workers.dev/r/motion.json"
  ],
  "files": [
    {
      "path": "registry/miseui/ui/radio-group.tsx",
      "content": "import type * as React from \"react\"\nimport { createContext, useContext, useId, useMemo, useState } from \"react\"\nimport { RadioGroup as RadioGroupPrimitive } from \"radix-ui\"\nimport { LayoutGroup, useReducedMotion } from \"motion/react\"\nimport {\n  ITEM_BASE_CLASS,\n  ITEM_CLASS,\n  ItemText,\n  PLAIN_LABEL_CLASS,\n  RadioIndicator,\n  ROOT_CLASS,\n  SelectionCheck,\n  type RadioGroupVariant,\n} from \"@/registry/miseui/ui/radio-group-parts\"\nimport { cn } from \"@/registry/miseui/lib/utils\"\n\ntype RadioGroupEffect = \"spring\"\n\ninterface RadioGroupContextValue {\n  variant: RadioGroupVariant\n  value: string | null | undefined\n  animated: boolean\n  reduceMotion: boolean\n}\n\nconst RadioGroupContext = createContext<RadioGroupContextValue>({\n  variant: \"plain\",\n  value: undefined,\n  animated: false,\n  reduceMotion: false,\n})\n\ntype RadioGroupProps = React.ComponentProps<typeof RadioGroupPrimitive.Root> & {\n  /** `plain` dots, `card` selectable surfaces, `segmented` joined buttons, `list` rows with a trailing check. */\n  variant?: RadioGroupVariant\n  /** `spring` slides one selection indicator between the options. */\n  effect?: RadioGroupEffect\n}\n\nfunction RadioGroup({\n  variant = \"plain\",\n  effect,\n  className,\n  value,\n  defaultValue,\n  onValueChange,\n  ...props\n}: RadioGroupProps) {\n  // layoutId is global to the page; without a per-instance group two groups would fight over one indicator.\n  const groupId = useId()\n  const reduceMotion = useReducedMotion() ?? false\n  const [uncontrolled, setUncontrolled] = useState<string | null | undefined>(defaultValue)\n  const current = value !== undefined ? value : uncontrolled\n  const animated = effect === \"spring\" && !reduceMotion\n  const context = useMemo(\n    () => ({ variant, value: current, animated, reduceMotion }),\n    [variant, current, animated, reduceMotion],\n  )\n\n  return (\n    <RadioGroupContext.Provider value={context}>\n      <LayoutGroup id={groupId}>\n        <RadioGroupPrimitive.Root\n          data-slot=\"radio-group\"\n          data-variant={variant}\n          data-effect={effect}\n          className={cn(ROOT_CLASS[variant], className)}\n          value={value}\n          defaultValue={defaultValue}\n          onValueChange={(next) => {\n            setUncontrolled(next)\n            onValueChange?.(next)\n          }}\n          {...props}\n        />\n      </LayoutGroup>\n    </RadioGroupContext.Provider>\n  )\n}\n\ntype RadioGroupItemProps = React.ComponentProps<typeof RadioGroupPrimitive.Item> & {\n  /** A second line. Shown by `plain`, `card` and `list`; `segmented` has no room and keeps it for assistive tech. */\n  description?: React.ReactNode\n}\n\nfunction RadioGroupItem({ value, description, className, children, ...props }: RadioGroupItemProps) {\n  const { variant, value: current, animated, reduceMotion } = useContext(RadioGroupContext)\n  const labelId = useId()\n  const descriptionId = useId()\n  const selected = current === value\n  const plain = variant === \"plain\"\n  const indicator = selected ? <RadioIndicator variant={variant} animated={animated} reduceMotion={reduceMotion} /> : null\n  const text = (\n    <ItemText\n      labelId={labelId}\n      descriptionId={descriptionId}\n      description={description}\n      hideDescription={variant === \"segmented\"}\n    >\n      {children}\n    </ItemText>\n  )\n  const item = (\n    <RadioGroupPrimitive.Item\n      data-slot=\"radio-group-item\"\n      value={value}\n      aria-labelledby={labelId}\n      aria-describedby={description ? descriptionId : undefined}\n      className={cn(ITEM_BASE_CLASS, ITEM_CLASS[variant], !plain && className)}\n      {...props}\n    >\n      {indicator}\n      {plain ? null : text}\n      {variant === \"card\" || variant === \"list\" ? <SelectionCheck variant={variant} selected={selected} /> : null}\n    </RadioGroupPrimitive.Item>\n  )\n  if (!plain) return item\n  return (\n    <label className={cn(PLAIN_LABEL_CLASS, className)}>\n      {item}\n      {text}\n    </label>\n  )\n}\n\nexport {\n  RadioGroup,\n  RadioGroupItem,\n  type RadioGroupProps,\n  type RadioGroupItemProps,\n  type RadioGroupVariant,\n  type RadioGroupEffect,\n}\n",
      "type": "registry:ui"
    },
    {
      "path": "registry/miseui/ui/radio-group-parts.tsx",
      "content": "import type * as React from \"react\"\nimport { Check } from \"lucide-react\"\nimport { motion } from \"motion/react\"\nimport { SPRING_DEFAULT } from \"@/registry/miseui/lib/motion\"\nimport { cn } from \"@/registry/miseui/lib/utils\"\n\ntype RadioGroupVariant = \"plain\" | \"card\" | \"segmented\" | \"list\"\n\n/**\n * `auto-rows-fr` and the equal-width segments keep every option the same size, so a flying indicator\n * never changes scale and its border and corners stay undistorted in the air, whatever the theme radius.\n */\nconst ROOT_CLASS: Record<RadioGroupVariant, string> = {\n  plain: \"grid gap-2 pointer-coarse:gap-0\",\n  card: \"grid auto-rows-fr grid-cols-[repeat(auto-fit,minmax(10rem,1fr))] gap-2\",\n  segmented: \"isolate inline-grid max-w-full auto-cols-fr grid-flow-col gap-1 rounded-lg bg-muted p-1\",\n  list: \"isolate grid divide-y overflow-hidden rounded-lg border\",\n}\n\nconst ITEM_BASE_CLASS = [\n  \"outline-none transition-[color,background-color,border-color,box-shadow] duration-(--duration-fast) ease-(--ease-mise)\",\n  \"focus-visible:ring-[3px] focus-visible:ring-ring/50\",\n  \"disabled:cursor-not-allowed disabled:opacity-50\",\n]\n\nconst ITEM_CLASS: Record<RadioGroupVariant, string> = {\n  plain: \"relative mt-0.5 size-4 shrink-0 rounded-full border border-input shadow-xs pointer-coarse:mt-0\",\n  card: \"relative flex items-start justify-between gap-3 rounded-lg border p-4 text-left shadow-xs enabled:hover:bg-accent/50\",\n  // No overflow clipping here: it would hide the indicator while it flies in from a neighbour.\n  segmented:\n    \"relative h-8 min-w-0 rounded-md px-3 text-sm font-medium text-muted-foreground enabled:hover:text-foreground data-[state=checked]:text-foreground pointer-coarse:h-10\",\n  list: \"relative flex min-h-12 w-full items-center justify-between gap-3 px-3 py-2 text-left enabled:hover:bg-accent/50 focus-visible:ring-inset\",\n}\n\nconst INDICATOR_CLASS: Record<RadioGroupVariant, string> = {\n  plain: \"absolute -inset-px flex items-center justify-center rounded-full bg-mise\",\n  card: \"pointer-events-none absolute -inset-px rounded-[inherit] border-2 border-mise\",\n  segmented: \"absolute inset-0 -z-10 rounded-[inherit] bg-background shadow-sm\",\n  list: \"absolute inset-0 -z-10 bg-accent\",\n}\n\nconst PLAIN_LABEL_CLASS =\n  \"flex items-start gap-2 has-disabled:cursor-not-allowed has-disabled:opacity-50 pointer-coarse:min-h-10 pointer-coarse:items-center\"\n\ninterface RadioIndicatorProps {\n  variant: RadioGroupVariant\n  animated: boolean\n  reduceMotion: boolean\n}\n\nfunction RadioIndicator({ variant, animated, reduceMotion }: RadioIndicatorProps) {\n  return (\n    <motion.span\n      aria-hidden=\"true\"\n      data-slot=\"radio-group-indicator\"\n      data-reduced={reduceMotion ? \"true\" : \"false\"}\n      layoutId={animated ? \"radio-group-indicator\" : undefined}\n      transition={SPRING_DEFAULT}\n      className={INDICATOR_CLASS[variant]}\n    >\n      {/* Mise can be pale; the dot in its foreground colour is what keeps the choice legible on any palette. */}\n      {variant === \"plain\" ? <span className=\"size-1.5 rounded-full bg-mise-foreground\" /> : null}\n    </motion.span>\n  )\n}\n\ninterface ItemTextProps {\n  labelId: string\n  descriptionId: string\n  description: React.ReactNode\n  hideDescription: boolean\n  children: React.ReactNode\n}\n\nfunction ItemText({ labelId, descriptionId, description, hideDescription, children }: ItemTextProps) {\n  return (\n    <span className=\"grid min-w-0 gap-1\">\n      <span id={labelId} className=\"block truncate text-sm leading-5 font-medium\">\n        {children}\n      </span>\n      {description ? (\n        <span\n          id={descriptionId}\n          className={hideDescription ? \"sr-only\" : \"block text-[13px] leading-5 font-normal text-muted-foreground\"}\n        >\n          {description}\n        </span>\n      ) : null}\n    </span>\n  )\n}\n\nfunction SelectionCheck({ variant, selected }: { variant: RadioGroupVariant; selected: boolean }) {\n  return (\n    <span\n      data-slot=\"radio-group-check\"\n      className={cn(\n        \"flex size-4 shrink-0 items-center justify-center rounded-full\",\n        variant === \"card\" && \"mt-0.5 border border-input shadow-xs\",\n        variant === \"card\" && selected && \"border-mise bg-mise text-mise-foreground\",\n      )}\n    >\n      {selected ? <Check aria-hidden=\"true\" className=\"size-3.5\" strokeWidth={variant === \"card\" ? 3 : 2.5} /> : null}\n    </span>\n  )\n}\n\nexport {\n  ROOT_CLASS,\n  ITEM_BASE_CLASS,\n  ITEM_CLASS,\n  PLAIN_LABEL_CLASS,\n  RadioIndicator,\n  ItemText,\n  SelectionCheck,\n  type RadioGroupVariant,\n}\n",
      "type": "registry:ui"
    }
  ],
  "categories": [
    "forms"
  ],
  "type": "registry:ui"
}