Back to Shark UI

Radio Group

docs/components/radio-group

latest7.2 KB
Original Source

Sections

Components

Utilities

Forms

Hooks

Radio Group

Copy Markdown

Allows single selection from multiple options.

DocsAPI

PreviewCode

Default

Confortable

Compact

Installation#

CLIManual

pnpmbunnpmyarn

pnpm dlx shadcn@latest add @shark/radio-group

Anatomy#

RadioGroup
└── RadioGroupItem

Usage#

import {
  RadioGroup,
  RadioGroupItem,
} from "@/components/ui/radio-group";
<RadioGroup>
  <RadioGroupItem value="item-1"></RadioGroupItem>
  <RadioGroupItem value="item-2"></RadioGroupItem>
</RadioGroup>

Controlled#

Use the value and onValueChange props to control the radio group.

PreviewCode

Select the option comfortable

Default

Comfortable

Compact

States#

Invalid#

Use the invalid prop on RadioGroup to indicate an invalid state.

PreviewCode

Default

Comfortable

Compact

Disabled#

Use the disabled on RadioGroup to disable all the radio group items or on RadioGroupItem to disable a single item.

PreviewCode

Default

Comfortable

Compact

Default

Comfortable

Compact

Examples#

With Description#

Use FieldDescription to add a description to the radio group.

PreviewCode

Default

Standard spacing for most use cases.

Comfortable

More space between elements.

Compact

Minimal spacing for dense layouts.

Card Style#

Use FieldLabel to wrap the entire Field for a clickable card-style selection.

PreviewCode

Plus

For individuals and small teams.

Pro

For growing businesses.

Enterprise

For large teams and enterprises.

API Reference#

RadioGroup#

Root component. Manages single selection from options.

PropTypeDefault
valuestring-
defaultValuestring-
disabledbooleanfalse
namestring-
onValueChange(details: ValueChangeDetails) => void-
classNamestring-

RadioGroupItem#

Single radio option. Use value for selection.

PropTypeDefault
valuestring-
disabledbooleanfalse
invalidbooleanfalse
classNamestring-

For a complete list of props, see the Ark UI documentation.

[

Previous page

QR Code ](/docs/components/qr-code)[

Next page

Rating ](/docs/components/rating)

On This Page

InstallationAnatomyUsageControlledStatesInvalidDisabledExamplesWith DescriptionCard StyleAPI ReferenceRadioGroupRadioGroupItem