radio
lyse/radioFreeComponent
lyse publishes no description for this item.
Live preview
live · rendered by the registry
Rendered by lyse on their own page — this is the component running, not a screenshot of it.Install it
npx shadcn@latest add https://ui.getlyse.com/r/radio.jsonSource
1import * as React from "react"2import * as RadioGroupPrimitive from "@radix-ui/react-radio-group"3import { cva, type VariantProps } from "class-variance-authority"45import { cn } from "@/lib/utils"6import "./radio.css"78const radioVariants = cva(9 "radio-indicator inline-flex items-center justify-center shrink-0 rounded-full transition-colors cursor-pointer",10 {11 variants: {12 size: {13 sm: "h-[var(--layout-size-xs)] w-[var(--layout-size-xs)]",14 md: "h-[var(--layout-size-sm)] w-[var(--layout-size-sm)]",15 },16 },17 defaultVariants: {18 size: "sm",19 },20 }21)2223function RadioGroup({24 className,25 ...props26}: React.ComponentProps<typeof RadioGroupPrimitive.Root>) {27 return (28 <RadioGroupPrimitive.Root29 data-slot="radio-group"30 className={cn("flex flex-col gap-[var(--layout-gap-md)]", className)}31 {...props}32 />33 )34}3536function Radio({37 className,38 size = "sm",39 label,40 description,41 disabled,42 ...props43}: React.ComponentProps<typeof RadioGroupPrimitive.Item> &44 VariantProps<typeof radioVariants> & {45 label?: string46 description?: string47 }) {48 const id = React.useId()4950 return (51 <div52 data-slot="radio"53 data-disabled={disabled || undefined}54 className={cn("flex items-start gap-[var(--layout-gap-md)]", className)}55 >56 <div className="flex items-center py-[var(--layout-padding-2xs)]">57 <RadioGroupPrimitive.Item58 id={id}59 className={cn(radioVariants({ size }))}60 disabled={disabled}61 {...props}62 >63 <RadioGroupPrimitive.Indicator64 className={cn(65 "radio-dot rounded-full",66 size === "sm" ? "size-1.5" : "size-2"67 )}68 />69 </RadioGroupPrimitive.Item>70 </div>71 {label && (72 <label73 htmlFor={id}74 className={cn(75 "flex flex-col",76 disabled ? "cursor-default" : "cursor-pointer"77 )}78 >79 <span80 className={cn(81 "font-accent radio-label",82 size === "sm" ? "text-content-note" : "text-content-body"83 )}84 >85 {label}86 </span>87 {description && (88 <span className="text-content-note radio-description">89 {description}90 </span>91 )}92 </label>93 )}94 </div>95 )96}9798export { RadioGroup, Radio, radioVariants }
What it pulls in
npm packages
Other registry items
Files it writes
More from lyse
All 33 items| Component | Registry | Kind | Access | Installs | Command |
|---|---|---|---|---|---|
| action-cardaction-card | lyse | Components | Free | no deps · 2 files | |
| alertalert | lyse | Components | Free | 2 deps · 2 files | |
| alert-dialogalert-dialog | lyse | Components | Free | 2 deps · 2 files | |
| avataravatar | lyse | Components | Free | 3 deps · 2 files | |
| badgebadge | lyse | Components | Free | 1 dep · 2 files | |
| banner-infobanner-info | lyse | Components | Free | 2 deps · 2 files | |
| breadcrumbbreadcrumb | lyse | Components | Free | 2 deps · 2 files | |
| buttonbutton | lyse | Components | Free | 2 deps · 2 files |
