@neynar/ui
Version:
React UI component library built on shadcn/ui and Tailwind CSS
73 lines (61 loc) • 2.09 kB
Markdown
for single selection Creates a group where only one radio item can be selected at a time. Manages the selection state and ensures mutual exclusivity between options. Use with DropdownMenuRadioItem components to create single-choice scenarios like theme selection, sorting options, or view modes.
```jsx
import { DropdownMenuRadioGroup } from '@neynar/ui';
<DropdownMenuRadioGroup
value="value"
onValueChange={handleValueChange}
disabled={true}
>
{/* Your content here */}
</DropdownMenuRadioGroup>
```
- **Type**: `string`
- **Required**: No
- **Description**: The currently selected value in the radio group
- **Type**: `(value: string) => void`
- **Required**: No
- **Description**: Callback fired when the selection changes to a different value
- **Type**: `boolean`
- **Required**: No
- **Description**: Whether the entire radio group is disabled
- **Type**: `React.ReactNode`
- **Required**: No
- **Description**: No description available
```tsx
// Theme selection with radio group
const [theme, setTheme] = useState("light");
<DropdownMenuRadioGroup value={theme} onValueChange={setTheme}>
<DropdownMenuRadioItem value="light">
<Sun className="mr-2 h-4 w-4" />
Light Theme
</DropdownMenuRadioItem>
<DropdownMenuRadioItem value="dark">
<Moon className="mr-2 h-4 w-4" />
Dark Theme
</DropdownMenuRadioItem>
<DropdownMenuRadioItem value="system">
<Monitor className="mr-2 h-4 w-4" />
System Theme
</DropdownMenuRadioItem>
</DropdownMenuRadioGroup>
```
```tsx
// Sorting options
const [sortBy, setSortBy] = useState("name");
<DropdownMenuRadioGroup value={sortBy} onValueChange={setSortBy}>
<DropdownMenuRadioItem value="name">Sort by Name</DropdownMenuRadioItem>
<DropdownMenuRadioItem value="date">Sort by Date</DropdownMenuRadioItem>
<DropdownMenuRadioItem value="size">Sort by Size</DropdownMenuRadioItem>
</DropdownMenuRadioGroup>
```
**Type**: component
Groups radio items