Radio Group
solid-ui/radio-groupFreeComponent
A radio group component
Live preview
live · rendered by the registry
Rendered by solid-ui on their own page — this is the component running, not a screenshot of it.Install it
npx shadcn@latest add https://www.solid-ui.com/r/radio-group.jsonSource
1import type { JSX, ValidComponent } from "solid-js"2import { splitProps } from "solid-js"34import type { PolymorphicProps } from "@kobalte/core/polymorphic"5import * as RadioGroupPrimitive from "@kobalte/core/radio-group"67import { cn } from "~/lib/utils"89type RadioGroupRootProps<T extends ValidComponent = "div"> =10 RadioGroupPrimitive.RadioGroupRootProps<T> & { class?: string | undefined }1112const RadioGroup = <T extends ValidComponent = "div">(13 props: PolymorphicProps<T, RadioGroupRootProps<T>>14) => {15 const [local, others] = splitProps(props as RadioGroupRootProps, ["class"])16 return <RadioGroupPrimitive.Root class={cn("grid gap-2", local.class)} {...others} />17}1819type RadioGroupItemProps<T extends ValidComponent = "div"> =20 RadioGroupPrimitive.RadioGroupItemProps<T> & {21 class?: string | undefined22 children?: JSX.Element23 }2425const RadioGroupItem = <T extends ValidComponent = "div">(26 props: PolymorphicProps<T, RadioGroupItemProps<T>>27) => {28 const [local, others] = splitProps(props as RadioGroupItemProps, ["class", "children"])29 return (30 <RadioGroupPrimitive.Item class={cn("flex items-center space-x-2", local.class)} {...others}>31 <RadioGroupPrimitive.ItemInput />32 <RadioGroupPrimitive.ItemControl class="aspect-square size-4 rounded-full border border-primary text-primary ring-offset-background focus:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:cursor-not-allowed disabled:opacity-50">33 <RadioGroupPrimitive.ItemIndicator class="flex h-full items-center justify-center ">34 <svg35 xmlns="http://www.w3.org/2000/svg"36 viewBox="0 0 24 24"37 fill="none"38 stroke="currentColor"39 stroke-width="2"40 stroke-linecap="round"41 stroke-linejoin="round"42 class="size-2.5 fill-current text-current"43 >44 <path d="M12 12m-9 0a9 9 0 1 0 18 0a9 9 0 1 0 -18 0" />45 </svg>46 </RadioGroupPrimitive.ItemIndicator>47 </RadioGroupPrimitive.ItemControl>48 {local.children}49 </RadioGroupPrimitive.Item>50 )51}5253type RadioGroupLabelProps<T extends ValidComponent = "label"> =54 RadioGroupPrimitive.RadioGroupLabelProps<T> & {55 class?: string | undefined56 }5758const RadioGroupItemLabel = <T extends ValidComponent = "label">(59 props: PolymorphicProps<T, RadioGroupLabelProps<T>>60) => {61 const [local, others] = splitProps(props as RadioGroupLabelProps, ["class"])62// … truncated
What it pulls in
npm packages
Files it writes
More from solid-ui
All 55 items| Component | Registry | Kind | Access | Installs | Command |
|---|---|---|---|---|---|
| Accordionaccordion | solid-ui | Components | Free | 2 deps | |
| Alertalert | solid-ui | Components | Free | 3 deps | |
| Alert Dialogalert-dialog | solid-ui | Components | Free | 2 deps | |
| Aspect Ratioaspect-ratio | solid-ui | Components | Free | 1 dep | |
| Avataravatar | solid-ui | Components | Free | 2 deps | |
| Badgebadge | solid-ui | Components | Free | 2 deps | |
| Badge Deltabadge-delta | solid-ui | Components | Free | 2 deps | |
| Bar Listbar-list | solid-ui | Components | Free | 1 dep |
