shadcn.io is an independent project built on shadcn/ui
Components
Free
Menu Dock for React
A bar of labeled icons for React and Base UI where the chosen item turns primary and an underline slides to it, in a row or a side rail.
On this page9 sections
Menu Dock is a bar of icons with their names under them. The chosen item takes the primary color, an underline slides beneath its label and the icon hops once. It fits the three to eight sections of an app, along the bottom of a phone screen, across the top of a panel or down the side as a rail.
For icons alone under a stronger marker, use Limelight Nav. When each choice swaps a panel in place, use Tabs.
Installation
Sign in to get your install command
Free with an account. It carries your token, so the CLI installs everything in one go.
The dock marks the enabled item whose value matches its defaultValue or value. That item gets data-active for styling and aria-current for screen readers.
MenuDock renders a nav landmark with no name of its own, so give it an aria-label such as Main or Workspace. Every item is a button, or your link through asChild, with its own place in the tab order, and the arrow keys along the dock, Home and End also move between items, skipping disabled ones. The chosen item gets aria-current, set to page on a link and to true on a button. MenuDockIcon is hidden from screen readers, so an item without a MenuDockLabel needs an aria-label.
KeyAction
Tab
Moves focus to the next item, and from the last one out of the dock.
Shift+Tab
Moves focus to the previous item, and from the first one out of the dock.
Arrow Right
In a horizontal dock, moves focus to the next item, and from the last one back to the first. In a right-to-left layout, moves to the previous item.
Arrow Left
In a horizontal dock, moves focus to the previous item, and from the first one to the last. In a right-to-left layout, moves to the next item.
Arrow Down
In a vertical dock, moves focus to the next item, and from the last one back to the first.
Arrow Up
In a vertical dock, moves focus to the previous item, and from the first one to the last.
Home
Moves focus to the first item.
End
Moves focus to the last item.
Enter
Chooses the focused item, following the link when the item is one.
Space
Chooses the focused item when it is a button. A link ignores it.
Demos
Sizes
The same five workspace sections at sizesm, default and lg, with Work chosen in each. The one prop sets the padding, the icons at 16, 20 or 24 pixels and the label's text together, and the underline follows the label at every size. Pick sm for a toolbar inside a panel and lg for a phone's bottom bar, where fingers need the room.
Vertical
With orientation set to vertical, Overview, Inbox, Team, Reports and Settings stack into a rail with Inbox chosen. The marker becomes a bar on the chosen item's leading edge, its right edge in a right-to-left layout, and Up and Down move focus instead of Left and Right. Use it for a narrow side rail next to the page's content.
Icon only
Five icons in a rounded pill with no MenuDockLabel, so the marker shrinks to a short bar under the chosen icon, Explore. Each MenuDockItem carries an aria-label, because the icon is hidden from screen readers. Keep icon-only docks to icons people know at a glance, like home, search and profile.
Controlled
A task list's four views, Inbox, Today, Starred and Done, with Today chosen and a line under the dock that counts its tasks. The view lives in state, goes in as value, and comes back as a plain string from onValueChange. Control the dock when something else on the page reads the choice, or when the route decides it.
FAQ
When should I use Menu Dock instead of Tabs or Bottom Navigation?
Use Menu Dock to move between an app's sections or pages. It's a nav that marks the current item with aria-current and renders no panels, so what changes is up to your page or your router.
Tabs fit when each choice reveals a panel in place, and they give that panel tab semantics. Bottom Navigation is a phone bar fixed to the bottom of the screen that swaps its own sections. For magnifying app icons, use Dock.
How do I control the Menu Dock's chosen item in React?
Keep the value in state, pass it as value on MenuDock and update it in onValueChange. The callback receives the chosen item's value as a plain string, so a state setter can go straight in, as in the Controlled demo.
For a starting item you don't need to control, use defaultValue. Leave both out and no item is marked until someone chooses one.
Can Menu Dock items be links in React?
Yes. Add asChild to each MenuDockItem and make an <a> or your router's link its only child, with the link's path as the item's value. The item's classes and click handler move onto the link.
The chosen link gets aria-current="page", which is right for navigation. Set the dock's value from the current path rather than defaultValue, so the underline follows the back button and a reload.
How do I pin the Menu Dock to the bottom of a phone screen?
Position it yourself, because MenuDock sits in the page's flow wherever you render it. Classes such as fixed inset-x-0 bottom-0 justify-around on MenuDock stretch it along the bottom edge and spread the items out, and the underline still lands on the chosen item, since it is measured from the dock.
Unlike Bottom Navigation, the dock adds no room for the iPhone home indicator. Pad its bottom with env(safe-area-inset-bottom), and give the page bottom padding as tall as the dock so its last lines aren't hidden underneath.
Why is the Menu Dock underline not showing?
The underline goes out when no enabled item matches the dock's value. Check the value for a typo, and check that the item it names isn't disabled.
Once an item matches, the underline sits under its label, as wide as the label and 2 pixels tall. Without a label it's a 16 pixel bar under the icon, and in a vertical dock a 3 pixel bar on the item's leading edge. The dock measures again when the value, orientation or size changes and whenever the dock or an item resizes, so a late font or a longer label doesn't strand it.
How do I change how the chosen Menu Dock item looks?
Add classes with the data-active: variant to MenuDockItem, since the chosen item carries data-active. A class such as data-active:bg-primary/10 adds a tint behind it. Its color ships as data-active:text-primary plus data-active:hover:text-primary, so override both, with data-active:text-foreground and data-active:hover:text-foreground for example, or hovering it brings the primary color back.
The underline is a separate span drawn by MenuDock, in bg-primary. There is no prop for it, so change its color or thickness in components/ui/menu-dock, which is your code once installed.
How do I turn off the Menu Dock's hop animation?
Set animated to false on MenuDock. A chosen icon then stays put when it's clicked, and the underline still slides to it.
When the system asks for reduced motion, the dock drops both on its own: the icon doesn't hop, the underline jumps to its place instead of sliding, and hover colors change without a fade. Nothing about the choice itself changes, so the chosen item is marked the same way.
Can I use the Menu Dock with the keyboard?
Yes. Each item is a button or a link in the tab order, and the arrow keys also move between items: Left and Right in a row, mirrored in a right-to-left layout, or Up and Down in a vertical dock, wrapping at the ends. Home and End jump to the first and last item.
Moving focus doesn't choose anything. Enter chooses the focused item, and so does Space when the item is a button. The Accessibility section lists every key.
API Reference
MenuDock
PropType
value?string
The active item, when controlled.
defaultValue?string
The item active at first, when uncontrolled.
onValueChange?(value: string) → void
Called with an item's value when it's chosen.
Parameters
value – string
Returns
void
animated?boolean
Whether a chosen item's icon hops once.
Default
true
orientation?"horizontal" | "vertical"
A row (an underline marks the active item) or a column (a bar on its
leading edge).
Type
"horizontal" | "vertical"
Default
"horizontal"
size?"sm" | "default" | "lg"
The items' padding, icons and text.
Type
"sm" | "default" | "lg"
Default
"default"
className?string
Merged with the part's classes.
CSS variableType
--menu-dock-heightstring
--menu-dock-widthstring
--menu-dock-xstring
The indicator's place, set from the active item.
--menu-dock-ystring
MenuDockItem
<button>data-slot="menu-dock-item"
PropType
valuestring
The item's value: the dock's value when it's active.
asChild?boolean
Use the provided child element as the default rendered element, combining their props and behavior.