ActionsMotionPause
Searchastronomic.dev# MotionPause
For the one Pause motion button a page with moving parts needs: it stops every marquee and autoplaying video for the visit. Put it in the first marquee.
Interactive: inline script.
## Usage
```astro
import MotionPause from "@astronomic-dev/ui/components/MotionPause.astro";
```
## Examples
### The pause button
One button per page, in the first marquee (pass pause to it), or on its own as here. A press sets data-motion-paused on <html>, which freezes every marquee, stops autoplaying video and turns the motion-ok variant off on the page (as calm does), and keeps the choice for the visit. Put motionScript from @astronomic-dev/ui/lib/motion.ts inline in the page's <head> too: it puts the pause back before the first paint of the next page.
```astro
---
import MarqueeText from "@astronomic-dev/ui/components/MarqueeText.astro";
import MotionPause from "@astronomic-dev/ui/components/MotionPause.astro";
---
<div class="mx-auto grid max-w-3xl gap-6">
<MotionPause />
<MarqueeText label="What the button stops" items={["Marquees", "Autoplaying video", "Anything else that loops"]} />
</div>
```
## Props
### MotionPause
| Prop | Type | Default | Description |
| --- | --- | --- | --- |
| `label` | `string` | `"Pause motion"` | The button's words, in your site's language. They stay the same when pressed: the pressed state (aria-pressed) says motion is paused. |
| `class` | `string` | None | More classes, merged with cn(), so yours win on conflicts. It takes the current text color: on another surface, set the color on its parent. |
Any other attribute goes on the <button>.
## Accessibility
| Key | Action |
| --- | --- |
| Enter or Space | Pauses every moving part on the page, or starts them again. |
- A native <button> with aria-pressed: pressed means motion is paused. The label stays "Pause motion", so a screen reader never says "Play motion, pressed", which reads backwards.
- Anything that moves for more than five seconds needs a way to stop it (WCAG 2.2.2): this is that way, for a reader who has not asked their system for reduced motion.
- Hidden when nothing moves (reduced motion, or the theme is calm) and without JavaScript, where it could not work.
- The choice is kept for the visit in sessionStorage as astronomic:motion-paused. Blocked storage is fine: the pause still holds for the page.
- At least 44px tall and wide on touch screens.
MotionPause
FreeFor the one Pause motion button a page with moving parts needs: it stops every marquee and autoplaying video for the visit. Put it in the first marquee.
- File
- MotionPause.astro
- Group
- Actions
- Kind
- Interactive: inline script
- Examples
- 1
Examples
Drag the orange handle to set the width. Frames get real breakpoints.
- Static
- Interactive
- Framed
The pause button
One button per page, in the first marquee (pass pause to it), or on its own as here. A press sets data-motion-paused on <html>, which freezes every marquee, stops autoplaying video and turns the motion-ok variant off on the page (as calm does), and keeps the choice for the visit. Put motionScript from @astronomic-dev/ui/lib/motion.ts inline in the page's <head> too: it puts the pause back before the first paint of the next page.
This preview did not load.
main.astro
examples/motionpause/main.astro
---
import MarqueeText from "@astronomic-dev/ui/components/MarqueeText.astro";
import MotionPause from "@astronomic-dev/ui/components/MotionPause.astro";
---
<div class="mx-auto grid max-w-3xl gap-6">
<MotionPause />
<MarqueeText label="What the button stops" items={["Marquees", "Autoplaying video", "Anything else that loops"]} />
</div>Minimal · Light