DÁP design system components are calm by default: they change state without decorative animation. The optional motion package adds short, purposeful transitions on top: selections that slide, digits that roll, content that grows open.
Motion is opt-in twice:
- Load the motion entry point,
dap-design-system/motion. Without it, no motion code is downloaded. - Add the
motionattribute to the components that should animate. Anything without it keeps its regular behaviour, so calm and animated forms can sit on the same page.
Motion never changes what a component does: values, events, focus, keyboard handling and ARIA stay exactly the same, with or without it.
// Components, as usual
import 'dap-design-system/components'
// Makes motion available
import 'dap-design-system/motion'
<script type="module" src="https://cdn.jsdelivr.net/npm/dap-design-system@1.0.0-beta.7/dist/components.js/+esm"></script>
<script type="module" src="https://cdn.jsdelivr.net/npm/dap-design-system@1.0.0-beta.7/dist/motion.js/+esm"></script>
<dap-ds-tab-group motion>
<dap-ds-tab tabId="overview">Overview<div slot="content">…</div></dap-ds-tab>
<dap-ds-tab tabId="payments">Payments<div slot="content">…</div></dap-ds-tab>
</dap-ds-tab-group>
The attribute can be added or removed at any time; the component picks the change up immediately.
Load dap-design-system/motion together with the components, before they are
rendered. Components already in the page when motion loads are picked up too,
but ones created earlier inside another component's shadow root are not.
The components below have motion on. Switch tabs, pick a card, tick the boxes
and step the number to see it. With reduced motion turned on in your system
settings, they change instantly.
Put motion on the component itself, or on the group or component listed in
the second column to cover everything inside it.
| Component | motion also works on | What animates |
|---|---|---|
dap-ds-radio-button | dap-ds-radio-group | The dot pops in with a slight spring; the control dips while pressed. |
dap-ds-radio-group | Card-style radios (type="background"): one selection ring slides to the chosen card. | |
dap-ds-tab-group | The selected-tab underline slides and resizes to the new tab; in mobile mode the side bar slides vertically. | |
dap-ds-number-input | When the value changes by the step buttons, arrow keys or your code, the changed digits roll up or down. Typing is never animated. | |
dap-ds-calendar | dap-ds-datepicker | Changing month slides the days in from the direction of travel; a newly selected day pops. |
dap-ds-button | Entering or leaving loading morphs the width instead of jumping; the button dips while pressed. | |
dap-ds-accordion | dap-ds-accordion-group | Content grows open and shrinks closed with its real height; the chevron flips. Toggling mid-way reverses from the current size. |
dap-ds-checkbox | dap-ds-input-group | The tick is drawn in and the box pops; the box dips while pressed. |
dap-ds-switch | dap-ds-input-group | The thumb springs across and stretches while pressed. |
A component rendered inside another one's shadow root also follows that
component's motion attribute: <dap-ds-datepicker motion> animates its
calendar, for example.
<!-- Every radio in the group, plus the sliding ring for card radios -->
<dap-ds-radio-group motion label="Split by" name="split" value="evenly">
<dap-ds-radio-button type="background" value="evenly" label="Split evenly"></dap-ds-radio-button>
<dap-ds-radio-button type="background" value="item" label="By item"></dap-ds-radio-button>
</dap-ds-radio-group>
<!-- Checkboxes and switches through their input group -->
<dap-ds-input-group motion label="Notifications">
<dap-ds-checkbox label="Email updates"></dap-ds-checkbox>
<dap-ds-switch label="Remind friends"></dap-ds-switch>
</dap-ds-input-group>
<!-- A single component -->
<dap-ds-button motion>Pay 24 000 Ft</dap-ds-button>
<dap-ds-number-input motion label="Guests" value="6"></dap-ds-number-input>
<dap-ds-datepicker motion label="Date of birth"></dap-ds-datepicker>
<dap-ds-accordion-group motion>…</dap-ds-accordion-group>
motion is a regular boolean attribute and property of the supported
components, typed in the custom-elements manifest, the editor integrations and
the React wrappers. In templates it is written like any other boolean attribute:
<!-- Vue, Angular, Svelte -->
<dap-ds-tab-group motion>…</dap-ds-tab-group>
With the React wrappers, it is a boolean prop:
import { DapDSTabGroupReact } from 'dap-design-system/react'
<DapDSTabGroupReact motion>…</DapDSTabGroupReact>
Setting the property (element.motion = true) works the same as the attribute.
On its own it does nothing: the attribute only takes effect once
dap-design-system/motion is imported.
- Reduced motion is always respected. When the user has
prefers-reduced-motion: reduceset, every motion is switched off, even wheremotionis present, and components change state instantly. - Motion is short (around 300 ms) and only follows something the user did or asked for; nothing loops or plays on its own.
- Nothing is announced differently: indicators, overlays and rolling digits are hidden from assistive technology, and the accessible names, states and focus order are unchanged.
- Timing is never relied on: a value is set the moment it changes, not when its animation ends.
Motion timing comes from four design tokens, defined in every theme. Override them globally, or on any element to tune a single component:
| Token | Default | Used for |
|---|---|---|
--dds-motion-easing-spring | cubic-bezier(0.34, 1.56, 0.64, 1) | Pops, springs and press release; slight overshoot |
--dds-motion-easing-emphasized | cubic-bezier(0.2, 0, 0, 1) | Slides and size changes; fast start, soft landing |
--dds-motion-duration-slide | 280ms | Indicators, month change, accordion, button morph |
--dds-motion-duration-pop | 320ms | Day and checkbox pops, rolling digits |
/* Calmer, slower motion everywhere */
:root {
--dds-motion-duration-slide: 400ms;
--dds-motion-easing-spring: var(--dds-easing-ease-out);
}
/* A snappier tab bar only */
dap-ds-tab-group.toolbar {
--dds-motion-duration-slide: 180ms;
}
See Animation tokens for all transition tokens.
The digit roll used by the number input is exported for your own displays, such as a total or a counter:
import { canRoll, rollText } from 'dap-design-system/motion'
const total = document.querySelector('#total')
function updateTotal(from, to) {
if (!canRoll()) {
total.textContent = to // no Web Animations API, or reduced motion
return
}
const direction = Number(to) > Number(from) ? 1 : -1
const roll = rollText(total, String(from), String(to), { direction })
roll.finished.then(() => {
total.textContent = to
})
}
rollText renders into the element you give it and rolls only the characters
that changed. Options: direction (1 up, -1 down), alignEnd (pair
characters from the end, for right-aligned text), duration, easing and
stagger. Keep the element aria-hidden while it rolls and expose the value
another way if it matters to assistive technology.
Motion does not change the components themselves. When the entry point loads,
it attaches a small controller to each supported component class. A controller
does nothing until motion is present; then it adds a motion stylesheet inside
the component's shadow root (scoped to the opted-in element) and runs short Web
Animations API animations on state changes. That is why it also works for
components nested inside other components' shadow roots, and why removing the
import removes every trace of it.
The controllers are exported (TabGroupMotionController,
SlidingIndicatorController, CssMotionController, …) along with
registerMotion(), which the entry point calls for you.