Motion
What moves in the kit, how it stops for readers who ask for less motion, and how to turn it down.
Most parts of Astronomic UI keep still. A few move on purpose: marquees, a fade-up as blocks enter the view, labels that roll on hover, and video loops. Each one stops on its own when the reader asks for less motion, and your site can stop them with one setting.
Who decides
Three switches stop motion. Any one of them is enough for what it covers.
| Switch | Who sets it | What it does |
|---|---|---|
| Reduced motion | The reader, in their device settings (prefers-reduced-motion: reduce) | The effects below stop. No click needed. |
| Calm | You, with data-motion="calm" on <html>, written on the server | The effects below stop, for every reader. |
| Pause motion | The reader, with the MotionPause button on the page | Marquees and autoplaying video stop. Other effects keep running. The choice is kept for the visit. |
Content is visible by default: with no JavaScript, with reduced motion, under calm and in print, nothing is hidden. A video the reader starts with its play button still plays under every switch. Only autoplay stops.
A few short transitions follow reduced motion but not calm: the Pro Tabs indicator and the Navbar links' color change on hover.
What moves
| Effect | Where | With reduced motion or calm |
|---|---|---|
| Marquee | Marquee, MarqueeLogos, MarqueeText, MarqueeTitle | The items sit still in rows. |
| Fade-up | Blocks you mark with data-reveal | Never starts. The blocks are there. |
| Text roll | Button roll, MobileMenu roll, the text-roll utility on your own links | The label stays still. |
| Icon tile turn or slide | Button iconTile (tileMotion) | The icon stays still. |
| Video loop | VideoMedia with autoplay | Shows the poster and a play button. The reader can still press play. |
| Shrinking nav | Navbar shrink | The bar switches to its narrow width at once. |
| Word fill | Pro Statement with fill | The words show in full ink. |
| Grayscale to color on hover | Pro Work grid | No transition. |
| Divider glide | Pro BeforeAfter, "All before" and "All after" | The divider moves at once. |
| Hover and press transitions | Buttons, links, the switch thumb | They change at once. |
The kit moves things mostly with transform and opacity. Some effects animate other properties: the shrinking nav's width, the Pro Tabs indicator's position and width, the color and shadow of Buttons on hover, the Work grid's color hover and the BeforeAfter glide. All are short.
A marquee also pauses on hover, and while keyboard focus is inside it, it shows its still rows so the focused link stays in place.
The pause button
Anything that moves for more than five seconds needs a way to stop it (WCAG 2.2.2). MotionPause is that way, for a reader who has not set reduced motion on their device.
Put one per page, in or beside the first marquee. A marquee shell places it for you when you pass pause:
---
import MarqueeLogos from "@astronomic-dev/ui/components/MarqueeLogos.astro";
---
<MarqueeLogos label="Trusted by teams like yours" items={logos} pause />Or put the button anywhere on its own:
---
import MotionPause from "@astronomic-dev/ui/components/MotionPause.astro";
---
<MotionPause />A press sets data-motion-paused on <html>. Every marquee freezes where it is, every autoplaying video stops, and the motion-ok variant turns off, as under calm: no fade-up, no rolling label, no transitions. The choice is kept for the visit in sessionStorage (key astronomic:motion-paused).
- The label stays "Pause motion".
aria-pressedcarries the state, so a screen reader never hears "Play motion, pressed". Passlabelto use your site's language. - The button hides itself under reduced motion or calm, and when JavaScript is off, where it could not work. A marquee moves only where scripts run, so with JavaScript off it shows its still rows and never moves without a pause button.
- On touch screens it is at least 44px tall and wide.
The motion script
The fade-up and the saved pause need a small inline script in the page's <head>, so they apply before the first paint. Add motionScript to your layout, and the reveal class on <html> if you use the fade-up:
---
import { motionScript } from "@astronomic-dev/ui/lib/motion.ts";
---
<html lang="en" class="reveal">
<head>
<script is:inline set:html={motionScript} />
</head>
</html>Then mark what should rise into view:
| Mark | What rises |
|---|---|
data-reveal | The element itself |
data-reveal="kids" | Its children, one after another |
data-reveal="hero" | A kit hero's text, line by line |
data-reveal="items" | The items of its list, one after another |
The script sets data-reveal-ready on <html> only when the browser can watch the view, the reader allows motion and the site is not calm. Without that flag the reveal rules do nothing.
Turn motion down
- Turn it off. Write
data-motion="calm"on<html>on the server. The effects in the table stop, and the pause button hides. - Slow a marquee. Pass
speed="slow"(or"fast") to a marquee shell. To change every marquee's base loop, set--ui-marquee-duration(default40s) in your CSS. - Leave an effect out. The fade-up runs only on blocks you mark. Roll, icon tiles,
autoplayandshrinkare props you can leave off.
Tip
Test your page with reduced motion on. In Chrome or Edge DevTools, open the Rendering panel and set "Emulate CSS media feature prefers-reduced-motion" to reduce.
Your own motion
The kit's theme.css adds a motion-ok variant. It applies only when the reader allows motion and the site is not calm. It is also off while the reader has pressed the pause button. Write your own animations and transitions with it, and they follow all three switches. (motion-allowed is the same gate without the pause, for something that must stay while paused, like the pause button itself.) For example:
<a class="text-muted hover:text-fg motion-ok:transition-colors motion-ok:duration-150" href="/about">About</a>Without the variant, the still state shows.