MultiButton — animated expanding icon-button group #9751
Unanswered
OneDayDance
asked this question in
Request
Replies: 1 comment
-
|
The MultiButton component is great for keeping row-level or toolbar actions compact while still showing labels on interaction. Here are some tips:
|
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
Component: MultiButton
What it does
A pill-shaped button group where each item shows only its icon at rest.
On hover (desktop) or first tap (mobile), the hovered item expands to
reveal its label while sibling items compress to icon-only width. The
total container width never changes — all motion is internal.
Three exports:
MultiButtonCompactMultiButtonMultiButtonGroupVariants & sizes
Supports the standard shadcn variants (
default,outline,secondary,ghost) and sizes (sm,md,lg).Use cases
without paying the permanent width cost
Touch behaviour
First tap expands the slot (label reveal); second tap fires the action.
Tapping outside collapses.
CompactMultiButtonfirst-tap expands thewhole group, second tap on an item reveals its label, third fires.
Dependencies
lucide-react(icons viaLucideIcontype)tailwind-merge+clsx(already required by shadcn)Demo
Open live demo →
Implementation notes
Width is computed analytically (icon cell width × N + max label width +
dividers) so the container never jumps — there's no
ResizeObserverorDOM measurement needed. The
MultiButtonGroupcontext uses a sharedregistry of per-instance max widths so every row in a table stays
pixel-identical without callers needing a
syncWidthToprop.Beta Was this translation helpful? Give feedback.
All reactions