shadcn.io is not affiliated with official shadcn/ui
Dropdown Menu examples · Editor
Alignment Options Dropdown Menu for React
A text alignment picker with Left, Center, Right and Justify, whose icon button shows the current choice.
Alignment reads best as an icon: the button shows the current direction at a glance. This dropdown menu holds Align Left, Align Center, Align Right and Justify as radio items, and the outline icon button swaps to the chosen alignment's icon. It fits rich text editors, email composers and slide tools.
Preview
Installation
FAQ
How does the alignment choice work?
Left starts selected. The values are left, center, right and justify, in one radio group, so picking one unchecks the others.
DropdownMenuRadioGroup takes value, and onValueChange receives the new value. Each DropdownMenuRadioItem has its value.
Why does the trigger icon change?
The button renders the left, center, right or justify icon depending on the current value, so it always shows the active alignment. Each row repeats the same icon before its label.
Why is Justify under a line?
A DropdownMenuSeparator sits inside the radio group, between Align Right and Justify, to set the full-width option apart. It doesn't split the group: Justify still unchecks the others.
How wide is the menu?
The menu is w-48. The trigger is an outline Button with size="icon-md" and aria-label set to Text alignment, since it has no visible text.
Related
- Text Formatting Dropdown Dropdown MenuA text formatting menu with bold, italic
- Heading Selector Dropdown MenuA heading level picker from H1 to H6
- Basic Button GroupThree rows of outline buttons joined into
- Dropdown with Checkboxes Dropdown MenuA View menu of checkbox rows that show or
- Block Type Selector Dropdown MenuAn Insert Block menu with text, list and
- Insert Options Dropdown Dropdown MenuAn insert menu behind a plus button for