DocumentationMotion

Open in Create
Search
astronomic.dev

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.

SwitchWho sets itWhat it does
Reduced motionThe reader, in their device settings (prefers-reduced-motion: reduce)The effects below stop. No click needed.
CalmYou, with data-motion="calm" on <html>, written on the serverThe effects below stop, for every reader.
Pause motionThe reader, with the MotionPause button on the pageMarquees 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

EffectWhereWith reduced motion or calm
MarqueeMarquee, MarqueeLogos, MarqueeText, MarqueeTitleThe items sit still in rows.
Fade-upBlocks you mark with data-revealNever starts. The blocks are there.
Text rollButton roll, MobileMenu roll, the text-roll utility on your own linksThe label stays still.
Icon tile turn or slideButton iconTile (tileMotion)The icon stays still.
Video loopVideoMedia with autoplayShows the poster and a play button. The reader can still press play.
Shrinking navNavbar shrinkThe bar switches to its narrow width at once.
Word fillPro Statement with fillThe words show in full ink.
Grayscale to color on hoverPro Work gridNo transition.
Divider glidePro BeforeAfter, "All before" and "All after"The divider moves at once.
Hover and press transitionsButtons, links, the switch thumbThey 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:

astro
---
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:

astro
---
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-pressed carries the state, so a screen reader never hears "Play motion, pressed". Pass label to 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:

astro
---
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:

MarkWhat rises
data-revealThe 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 (default 40s) in your CSS.
  • Leave an effect out. The fade-up runs only on blocks you mark. Roll, icon tiles, autoplay and shrink are 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:

html
<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.

Waitlist

Be first in line

Join the waitlist and we'll email you the moment it's out.

You'll also get our newsletter: new themes, plugins and guides. Unsubscribe any time.