A status button made of a pile of slabs: a click tucks the top slab under and the next state lands on top, and a hint says where the click goes.
Click meTap me
Changelog · v2.4
Saved views for every table
Pin a set of filters and columns, then share it with your workspace.
Send to review. Shift + click: Publish.
Only you can see this post
stack-cycle · , lively
stack-cycle-demo.tsx
When to use
Use it for a status that advances one step at a time in a fixed order of two to five states. A hint on hover or focus says where the click goes; Shift plus click steps back.
When not to use
For values that are picked rather than stepped through use Segmented Control. For a plain on/off setting use Switch.
Use Stack Cycle for a status that advances one step at a time in a fixed order: a post that goes Draft, In review, Published; a priority; an estimate; a Watch toggle. The button is a pile of slabs: the top slab is the current state and the next one already shows underneath, so the order is visible before anyone clicks. A click pulls the top slab out sideways and tucks it under, and the next state lands on top with a squash. On hover or keyboard focus, the next slab slides out a little and a hint above the pile says where the click goes ("Send to review"); holding Shift flips it to the previous state. For values that are picked rather than stepped through (a view switcher, more than five options), or a row with no free room on the button's end side, use a segmented control or a select.
states holds two to five { value, label, icon?, tone?, color?, action? } in cycle order (extra entries are ignored). value / defaultValue select the current one and onValueChange runs after each step. label names what the button sets: the accessible name reads "Status: Draft". A click steps forward; Shift + click steps back.
With hint (on by default), hovering the button or focusing it from the keyboard floats a chip above the pile that says where the click goes: the next state's action ("Send to review") or, without one, "Next: In review", plus a "⇧ back" reminder. Holding Shift flips it to the previous state ("Back: Draft"). The same sentence is the button's accessible description, merged with your own aria-describedby. The chip is absolutely positioned (nothing moves) and leaves room for itself only if you do: keep about 36 px free above the button, or set hint={false}. Touch has no hover, so the chip never sticks after a tap. Toggles show it only when their states have an action.
Each slab has a tone: solid (the tone itself, white text), soft or paper (tints with card-foreground text). By default the first state is solid, then soft, then paper. color replaces the customer's primary for one slab, for example var(--destructive) for an Urgent priority.
Two states make a toggle with aria-pressed on the second. Its name is label, so keep the visible label the same in both states and change the icon or tone instead; an action per state gives the toggle a hint ("Get updates"):
Presets set where the pile shows: deck (default, down and to the right, like a deck of cards), pile (bands under the slab) and ledge (strips at the right edge, for tall toolbars and narrow cells). offset overrides the distance between slabs in px; size is sm (32 px), md (40 px) or lg (48 px). The width is reserved for the longest label. The pulled slab travels one slab width past the end (right) edge in both directions: keep that side of the row clear.
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 changelog post in a CMS. The Status button advances the post from Draft to In review to Published, and the line under it says who can see the post now. Each state has an action, so the hint reads "Send to review" or "Publish". The pile turns once by itself when the card comes into view.
Click meTap me
Changelog · v2.4
Saved views for every table
Pin a set of filters and columns, then share it with your workspace.
An issue's detail panel: a two-state Watch toggle under the title (its hint reads "Get updates"), a four-step Priority whose Urgent slab uses var(--destructive), and an Estimate that is disabled for the running sprint.
Click meTap me
LUM-218
Audit log filters
Get updates.
Priority
Next: High. Shift + click: Back: Low.
Estimate
Next: L · 1 week. Shift + click: Back: S · ½ day.Locked in sprint
StackCycle renders one native button. With two states it is a toggle (aria-pressed on the second state) named by label; with three to five it is named "label: current state" and each change is announced in a polite live region.
The slabs, their faces, the width sizer, the hint chip and the focus ring are aria-hidden: the button's name carries the state, so the pile is read once.
With hint, the button is described by the next step and the Shift + click step ("Send to review. Shift + click: Publish."), after any aria-describedby you pass.
disabled uses the native attribute; pair it with aria-describedby to say why (the Estimate row in the example).
Slabs take the customer's --primary when it has color, else --brand, at a fixed lightness (L 0.55) in both themes: white text on solid slabs stays at least 4.5:1, and soft and paper slabs use card-foreground on a light tint. A state's color follows the same recipe.
Each slab has a 1 px hairline (foreground at 14% in light, the slab's own tone in dark), a rim light along its top and a soft shadow tinted with its color, so the pile never reads as a disabled gray on a dark card.
The focus ring outlines the top slab's rest box; keyboard focus also slides the next slab out, as hover does.
The pile stays still: no pull, tuck, squash, charge or peek. The label and color of each slab crossfade to the next state in 120 ms, so every state change stays visible, and the live region still announces it. The hint chip still shows on hover and focus, fading in place without rising.
One linear timeline drives every slab per turn: only transform, opacity and z-index change, and the label never deforms (it rides with the middle of a squashed slab).
There is no loop and nothing runs at rest (the hint listens for Shift only while it shows); a turn lasts under a second and is stopped on unmount.
At most three slabs show, plus one hidden behind the third for five states. The width is measured when a turn starts, never per frame.
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, hover, keyboard focus
Reduced motion
The pile stays still: no pull, tuck, squash or charge; the label and color of each slab crossfade to the next state in 120 ms; the hint chip fades in place.
Keyboard
Enter / Space
Charges while held, then turns the pile to the next state
Shift + Enter / Shift + Space
Turns the pile back to the previous state
Browsers
Last 2 versions of Chrome, Edge, Firefox and Safari (iOS 16.4+)