Icon Morphs
Animate a menu trigger between closed and open states.
Installation
pnpm dlx shadcn@4.18.0 add @siteplane/icon-morphsComplete the one-time setup first. Registry JSON lists source files and dependencies.
For this page’s examples, also install:
pnpm dlx shadcn@4.18.0 add @siteplane/collapsibleUsage
import { MenuIconMorph } from "@/siteplane/components/icon-morphs";
<MenuIconMorph />;Controlled navigation
Control open to show your navigation and point aria-controls at it. Pass the same open to a Collapsible and render the navigation as its panel: the list expands and collapses with the Collapsible’s motion, which is instant with reduced motion. keepMounted keeps the closed panel in the page, hidden, so aria-controls always finds it. The button sets aria-expanded and switches between “Open navigation menu” and “Close navigation menu”. The links are Buttons with variant="text" and profile="navigation-link", the rows of a mobile menu, and aria-current="page" marks the current one.
Sizes
Each size uses the matching Button icon size, from icon-sm to icon-xl.
API reference
| Prop | Type | Default | Description |
|---|---|---|---|
open / default | boolean | false | Controlled or initial expanded state. |
on | (open: boolean) => void | unset | Requested next state. |
on | MouseEventHandler | unset | Runs first; preventDefault cancels the toggle. |
size | sm | md | lg | xl | provider / lg | Icon control size. |
aria-label | string | Open navigation menu / Close navigation menu | Name reflects state unless overridden. |
type | button | submit | reset | button | Native button type. |
disabled | boolean | false | Prevents changing state. |
MenuIconMorphProps extends ButtonBaseProps without aria-expanded,
children, size, and variant. The recipe owns aria-expanded, the three
bars, and the borderless text styling. className styles the button inside
the root span. There are no separate morph parts or menu panel exports.
Usage notes
Space and Enter toggle the button. Point aria-controls at the navigation you show. Pass aria-label to replace the default open and close label. With reduced motion, from the operating system or a reduced motion preset, the bars change without animation.