sdxc

Type to search, or start from one of these:

[ @sdxc/ui/animations ]

pulse

Gentle opacity breathe for a skeleton placeholder, resolved entirely to @keyframes so it runs from server-rendered markup.

import { pulse } from "@sdxc/ui/animations";

Usage

Gentle opacity breathe for a skeleton placeholder, resolved entirely to @keyframes so it runs from server-rendered markup. Reduced motion narrows the swing by overriding duration and the min-opacity token alone.

Signature

pulse<Node extends Element = Element>(options?: Pulse.Options): Mixin<Node>

Returns a @sdxc/u mixin ready for a skeleton placeholder's host element.

Parameters

ParameterTypeDescription
options?Pulse.OptionsTiming, opacity range, and gating for the loop.

Examples

<Skeleton mix={[pulse()]} aria-hidden="true" />

The events, constants and types its module publishes, each imported from @sdxc/ui/animations too.

Interface

Pulse.Options

Tuning for a pulse loop: timing, opacity range, and the platform state it runs under.

MemberTypeDescription
duration?stringLength of one breathe cycle, as a CSS time. Defaults to DEFAULT_PULSE_DURATION.
easing?stringCSS easing function driving the breathe. Defaults to DEFAULT_PULSE_EASING.
minOpacity?numberDimmest point of the breathe, from 0 to 1. Defaults to DEFAULT_PULSE_MIN_OPACITY.
maxOpacity?numberBrightest point of the breathe, from 0 to 1. Defaults to DEFAULT_PULSE_MAX_OPACITY.
when?stringSelector fragment, relative to the host (e.g. [aria-busy="true"]), that gates the loop. Left unset, the loop runs as soon as it is mixed in, matching a skeleton mounted only while its content loads.

Written by Sergio Xalambrí. Follow @sergiodxa for new packages, or sponsor the work.