Primitives
Radio Group
Radix radio group with a springy selected dot.
Motionindicator scale-in on spring.bouncy
Install
Install Kineto and follow the theme setup once in your app.
bash
npm install kinetotsx
import { RadioGroup, RadioGroupItem } from "kineto/radio-group";Preview
tsx
"use client";
import * as React from "react";
import * as RadioGroupPrimitive from "@radix-ui/react-radio-group";
import { motion } from "motion/react";
import { cn } from "@/lib/cn";
import { spring } from "@/lib/motion-presets";
const RadioGroup = React.forwardRef<
React.ElementRef<typeof RadioGroupPrimitive.Root>,
React.ComponentPropsWithoutRef<typeof RadioGroupPrimitive.Root>
>(({ className, ...props }, ref) => (
<RadioGroupPrimitive.Root
ref={ref}
className={cn("grid gap-2.5", className)}
{...props}
/>
));
RadioGroup.displayName = "RadioGroup";
const RadioGroupItem = React.forwardRef<
React.ElementRef<typeof RadioGroupPrimitive.Item>,
React.ComponentPropsWithoutRef<typeof RadioGroupPrimitive.Item>
>(({ className, ...props }, ref) => (
<RadioGroupPrimitive.Item
ref={ref}
className={cn(
"aspect-square size-5 rounded-full border border-input bg-card shadow-xs transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 focus-visible:ring-offset-background disabled:cursor-not-allowed disabled:opacity-50 data-[state=checked]:border-brand",
className
)}
{...props}
>
<RadioGroupPrimitive.Indicator asChild>
<motion.span
initial={{ scale: 0.5, opacity: 0 }}
animate={{ scale: 1, opacity: 1 }}
transition={spring.bouncy}
className="flex h-full items-center justify-center"
>
<span className="size-2.5 rounded-full bg-brand" />
</motion.span>
</RadioGroupPrimitive.Indicator>
</RadioGroupPrimitive.Item>
));
RadioGroupItem.displayName = "RadioGroupItem";
export { RadioGroup, RadioGroupItem };src/components/ui/radio-group.tsx
Props
| Prop | Type | Default | Description |
|---|---|---|---|
| value / defaultValue | string | — | Controlled or uncontrolled selection. |
| onValueChange | (value: string) => void | — | Fires on change. |