Inline and page-top alerts whose icon disc rolls in and unrolls the banner; an error resolves into a success in place and can leave on a draining timer.
Trigger itTrigger it
Invoices and payment method for this workspace.
#2041
Nov 1
#1987
Oct 1
alert, lively
Use an alert for a message that stays until it is resolved: a form that could not be saved, a failed payment, a trial that is ending, a read-only window. It sits in the page, in the flow, at the place it concerns. For a transient confirmation of something the person just did (saved, copied, archived) use a toast; for a decision that blocks the page use a dialog.
The motion follows the three beats. The alert charges as its icon disc: a ball in the tone's
tint that rolls 24 px onto its slot, the glyph turning with it, and squashes on landing. It
acts by unrolling the tile out of the disc toward the right edge while the title rises. It
settles as the description and the actions cascade in and the dismiss button pops last. The
alert's box is reserved from the first frame, so nothing below moves while it arrives. Dismissing
plays it backwards: the parts leave first, the tile rolls back into the disc, the disc pops, and
the space closes on a calm spring (the neighbour's gap closes with it). Error alerts and alerts in
a group always move calm: the disc glides and lands round, nothing bounces. calm shortens the
unroll; playful flattens the disc clearly on landing.
An alert is a small state machine, not a static box. When its tone changes in place (the retry
worked), the same alert resolves: the disc squashes, the new glyph rolls in a half turn over the
old one, the tint crossfades and the tile follows the new text's height. With duration, a thin
rim in the tone's ink drains around the tile and the alert dismisses itself when it runs out; it
holds while the pointer is over it, while focus is inside and while the tab is hidden. In the
demo, press "Retry payment": the error turns into a receipt notice that leaves on its own, and the
invoice below turns from Failed to Paid.
pnpm dlx shadcn@latest add @motionkit-pro/alertnpx shadcn@latest add @motionkit-pro/alertyarn dlx shadcn@latest add @motionkit-pro/alertbunx --bun shadcn@latest add @motionkit-pro/alertRequires a Pro license and the @motionkit-pro registry with your token. See Installation.
import {
Alert,
AlertAction,
AlertActions,
AlertDescription,
AlertTitle,
} from "@/components/ui/alert"
export function PaymentNotice({ paid, retrying, retry }: PaymentNoticeProps) {
return (
// Errors stay; once paid, the same alert turns green and leaves after 6 s.
<Alert tone={paid ? "success" : "error"} duration={6000} dismissible>
<AlertTitle>{paid ? "Invoice #2041 is paid" : "Invoice #2041 was declined"}</AlertTitle>
<AlertDescription>
{paid ? "The receipt is in your inbox." : "Retry or use another card."}
</AlertDescription>
{paid ? null : (
<AlertActions>
<AlertAction variant="primary" loading={retrying} onClick={retry}>
Retry payment
</AlertAction>
</AlertActions>
)}
</Alert>
)
}Alert, AlertTitle and AlertDescription keep shadcn's names, and variant="destructive" maps
to tone="error", so existing alerts keep working. Every part is also on the namespace
(Alert.Title, Alert.Actions, Alert.Dismiss, Alert.Group, ...).
info (default), success, warning, error (alias destructive), neutral. A
tone changes the tint, the rim, the disc and the glyph, never the text colour.defaultOpen) or controlled (open and onOpenChange). The
dismiss sequence runs when open turns false; turning it true again plays the entrance.appear: mount (default), inView (default for banner: it plays once, when it scrolls
into view) or none for alerts already there when the page loads (server-rendered, at rest).AlertAction is a secondary rimmed tile or a primary filled one, 32 px tall.
loading puts a turning arc in the leading-icon slot (the label stays; a leading icon is
swapped, so the width holds), ignores clicks and disables the other actions;
asChild renders a link with the same look.dismissible (default for banner) adds the 28 px dismiss button; place
Alert.Dismiss yourself to control it. Its onClick runs first and event.preventDefault()
keeps the alert.sm (20 px disc, 12 px padding, smaller description) for dense panels.tone on an open alert (error to success after a retry) and swap its
text: it resolves in place instead of leaving and arriving. An alert that was not live
(appear="none") becomes live from that change, so the resolution is announced.duration (milliseconds) dismisses inline and banner alerts on their
own, with a draining rim. error alerts never auto-dismiss: the timer starts when the tone
leaves error and restarts on every tone change. callout ignores it (a note stays).AlertGroup max={2} shows the first two alerts and folds the rest behind a
"+N more" button whose count rolls when alerts are added or removed; the folded alerts slide
open on the calm spring. defaultExpanded starts it open.inline (default): a tile inside a form or a card; disc, title, description, actions under the
text.banner: page-top, the full width of the content area, one row when there is room (disc, text,
actions, dismiss) and stacked on narrow screens with full-width actions. Dismissible, plays on
viewport entry, sticky keeps it under the top of its scroll container. Trial ending,
maintenance windows, read-only mode.callout: quieter, no disc. A 4 px rail of the tone's colour draws top to bottom on the leading
edge of a muted panel. For docs-like contexts: explaining scopes on an API keys page.Prop
Type
Also accepts all props of Omit<ComponentProps<"div">, "role">.
Prop
Type
Also accepts all props of HTMLMotionProps<"h5">.
Prop
Type
Also accepts all props of HTMLMotionProps<"button">.
Prop
Type
Also accepts all props of ComponentProps<"div">.
banner)A plan page with a page-top warning: one row on wide screens, stacked with full-width actions on narrow ones. Dismiss it to see it roll back into its disc and the space close.
Trigger itTrigger it
Seats and renewal for this workspace.
alert, lively
Alert.Group)A "Create invoice" form submitted with three problems. The errors arrive one stagger step apart,
on the calm spring, 8 px apart; max={2} folds the third behind "+1 more". Press "Send invoice"
to replay.
Trigger itTrigger it
Invoice #1042 · Draft
alert, lively
callout)An info callout explains what each key scope allows above the list of keys.
Trigger itTrigger it
Keys let your services call this workspace's API.
Reporting export
mk_live_••••4821
Order sync
mk_live_••••0937
alert, lively
error and warning alerts are role="alert" (assertive); info, success and
neutral are role="status" (polite); callout is role="note" (not announced). Alerts with
appear="none" (there when the page loads) are not live regions, so a static trial banner is
not read out on every page load. live overrides all of this.focusOnMount (an error summary at the top of a form):
it then takes focus as it appears and shows the focus ring around its 12 px corners. After a
dismiss, focus moves to the next focusable element after the alert, never to the page body.duration follows WCAG 2.2.2: the timer holds while the pointer is over the alert or focus is
inside it, and errors never time out. Keep timed alerts for confirmations that are also
reachable elsewhere (the receipt in the inbox, the invoice row turning Paid).button with aria-expanded, named "Show 2 more" while
folded; aria-controls points at the unfolded alerts.sm). All have a visible focus ring.card-foreground) and description (muted-foreground) sit on a 6% tone tint and keep
AA contrast in both themes, including warning. Glyphs are the tone pulled toward the
foreground so they reach 3:1 on their disc.| Keys | Action |
|---|---|
| Tab / Shift+Tab | Moves through the alert's links, actions and dismiss button in reading order |
| Enter / Space | Runs the focused action or dismisses; focus then moves to what follows the alert |
| Enter / Space | On a group's "+N more" button: unfolds or folds the remaining alerts |
| Escape | Nothing: an alert is not an overlay, it stays until resolved |
With reduced motion (the OS setting, or MotionKitProvider reducedMotion="always") the disc does
not roll or squash and the tile does not unroll: the alert fades in already at rest, with its tinted
tile, rim, shadow, highlight and toned disc, the exact last frame of the animated version. The
description, actions and dismiss fade in together. The callout rail is drawn at once. A dismiss
fades the alert out and closes the space in the same short fade time. The loading arc rests at
three quarters of a turn. A tone change crossfades the glyph and the tint without turning or
squashing; a group fold fades. The duration rim still drains: it is the timer, linear and slow,
not decoration.
transform and opacity on Motion
springs; the unroll uses Motion's shared layout between the disc and the tile, with the rim
counter-scaled so it never thickens.duration timer is one Motion value driving the rim's stroke-dasharray, paused (not
restarted) on hover, focus and hidden tabs, stopped on unmount.IntersectionObserver, disconnected after the
first entry. The loading arc is a CSS rotation that only exists while an action is busy.motion (peer) and @radix-ui/react-slot (under 1 kB gzip, for asChild).Main spring of each temperament. Set it with the temperament prop or MotionKitProvider; the default is lively.
Not measured yet · budget 15.0 kB gzip
Component and MotionKit helpers; excludes react, react-dom, @radix-ui/react-slot, motion.
an app event, entering the viewport, click
No roll, squash or unroll: the alert fades in already at rest with its tinted tile, rim and toned disc, a tone change crossfades, the callout rail is drawn at once, and a dismiss fades out before the space closes in the same fade time.
Last 2 versions of Chrome, Edge, Firefox and Safari (iOS 16.4+)