UNPKG

@neynar/ui

Version:

React UI component library built on shadcn/ui and Tailwind CSS

73 lines (61 loc) 2.09 kB
# DropdownMenuRadioGroup **Type**: component Groups radio items 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 Usage ```jsx import { DropdownMenuRadioGroup } from '@neynar/ui'; <DropdownMenuRadioGroup value="value" onValueChange={handleValueChange} disabled={true} > {/* Your content here */} </DropdownMenuRadioGroup> ``` ## Component Props ### value - **Type**: `string` - **Required**: No - **Description**: The currently selected value in the radio group ### onValueChange - **Type**: `(value: string) => void` - **Required**: No - **Description**: Callback fired when the selection changes to a different value ### disabled - **Type**: `boolean` - **Required**: No - **Description**: Whether the entire radio group is disabled ### children - **Type**: `React.ReactNode` - **Required**: No - **Description**: No description available ## Examples ### Example 1 ```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> ``` ### Example 2 ```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> ```