Use Gate Button when one action comes in two or three flavours and the choice belongs right where the action is: deploy to Preview or Live, export as CSV, PDF or JSON, a destructive step that asks once. The pill breaks in two, the halves slide apart, their cut ends round into half balls and the choices rise in the gap; choosing, Escape or a click outside clacks it shut. The choices never cover the page and the width of the open gate is reserved, so nothing around it moves. For more than three choices or choices with descriptions, use a dropdown menu; for a single action, use a regular button.
The children are the word on the left half; choices holds one to three { value, label, icon? } (extra entries are ignored). onChoose runs with the chosen value before the gate shuts. The right half shows a chevron that turns toward the choices; pass icon to replace it. open, defaultOpen and onOpenChange control the gate; opening from the open prop never moves focus.
With remember, the left half shows the last choice and the choices become radio items with a dot on the chosen one, like a compact select (value / defaultValue):
Presets: gate (default, the shut pill rests in the middle of its reserved width and both halves swing out), latch (rests at the end, for a right-aligned toolbar: the right half stays, the left swings out) and confirm (one destructive choice; the gate shuts by itself after 4 s, paused under the pointer). anchor (start, center, end), tone (primary, destructive) and autoClose (ms or false) override the preset. size is sm (32 px), md (40 px) or lg (48 px); variant is outline or secondary.
Set the character for the whole app with MotionKitProvider, or per instance with temperament (calm, lively, playful). It changes motion intensity only, never the drawing.
The default demo: a release card whose one call to action is a Deploy gate with two targets. It opens once by itself when the card comes into view, then shuts.
An API keys panel: the header gate remembers the listed environment, and each row's confirm gate asks once before revoking a key and gives up after 4 s.
Menu-button pattern: the trigger is a native button with aria-haspopup="menu", aria-expanded and aria-controls. The choices are menuitem buttons (menuitemradio with aria-checked when remember is on) in a horizontal role="menu", named by menuLabel or, by default, by the trigger.
The choices stay in the DOM; while the gate is shut the menu is inert and aria-hidden. Focus moves into the gate only when the person opened it, and returns to the trigger on choose or Escape.
The word is read once from a visually hidden copy; the animated copies, the halves, the seam, the chevron, the inside and the drain band are aria-hidden.
The inside uses the customer's --primary when it has color, else --brand, at a fixed lightness (L 0.55) in both themes: white choices stay at least 4.5:1. The destructive inside is darker (L 0.48) so white text stays 4.5:1 under the drain band.
The halves use card (or secondary) with a rim at 16% foreground in light; in dark they are tinted with 18% of the tone and the rim rises to 34% foreground, so the edge reads on a dark card.
The focus ring follows the shut pill and fades as the halves part; each choice has its own ring.
No sink, overshoot or clack: the halves glide apart and back in a 120 ms tween with the ends rounding along, and the choices fade in place. The remembered word crossfades instead of rising. The seam, the inside, the choices and the confirm drain band are all still drawn.
One progress value drives the halves, the inside, the rounded ends, the seam and the chevron: only transform, opacity and border-radius change while it moves.
There is no loop. The widths are measured once and again only when a ResizeObserver reports a change, never per frame.
The confirm drain is a single linear tween that runs only while the gate is open and pauses under the pointer.
The outside-press listener is attached only while the gate is open.
Technical sheet
Motion
calm
260 ms · bounce 0
lively
400 ms · bounce 0.3
playful
540 ms · bounce 0.45
Main spring of each temperament. Set it with the temperament prop or MotionKitProvider; the default is lively.
Size
Not measured yet · budget 15.0 kB gzip
Component and MotionKit helpers; excludes react, react-dom, motion.
Dependencies
motion · peer
Triggers
click, press, keyboard focus
Reduced motion
No sink, overshoot or clack: the halves glide apart and back in a 120 ms tween with the ends rounding along, and the choices fade in place.
Keyboard
Enter / Space
Charges while held, then opens the gate on the first (or remembered) choice; on a choice, chooses it
Arrow Down / Arrow Right
On the button: opens on the first choice. In the gate: next choice (wraps)
Arrow Up / Arrow Left
On the button: opens on the last choice. In the gate: previous choice (wraps)
Home / End
First or last choice
Escape
Shuts the gate and returns focus to the button
Tab
Shuts the gate and moves focus on
Browsers
Last 2 versions of Chrome, Edge, Firefox and Safari (iOS 16.4+)