Skip to main content
Introducing packages.sweber.dev
Documentation menuCSS only

CSS only

data-sigmoid attributes, custom properties and the easing variables.

@sweberdev/sigmoid/sigmoid.css (about 4 kB, uncompressed) animates elements with a data-sigmoid attribute. Inside @supports (animation-timeline: view()) and prefers-reduced-motion: no-preference, so other browsers and users who prefer less motion see the content without animation.

Presets

ValueEffect
fade-inopacity
fade-up, fade-downopacity and vertical movement
slide-left, slide-rightopacity and horizontal movement
scale-inopacity and scale from 94%
blur-inopacity and blur
clip-uprevealed from the bottom with clip-path
rotate-inopacity, a slight turn and scale
flip-upopacity and a 3D tilt towards the reader
parallaxmoves against the scroll direction while crossing the viewport
progressscales from 0 to 100% width with the page scroll, e.g. a reading bar
counta number that counts up to --sigmoid-count

Tuning with custom properties

<li data-sigmoid="fade-up"
    style="--sigmoid-range: entry 10% cover 50%;
           --sigmoid-easing: var(--sigmoid-ease-bouncy);
           --sigmoid-distance: 48px">
PropertyDefaultMeaning
--sigmoid-rangeentry 0% cover 40%CSS animation-range on the element's view timeline
--sigmoid-easingvar(--sigmoid-ease-out)any CSS easing
--sigmoid-distance24pxmovement of the fade-* and slide-* presets
--sigmoid-parallax60pixels for parallax, without unit
--sigmoid-index0position in a list, for staggering
--sigmoid-stagger8%how much later each index starts (with %)

Counting numbers

<span data-sigmoid="count" style="--sigmoid-count: 1200" role="img" aria-label="1200"></span>

The element shows its number through CSS, so it stays empty in the markup: give it a role="img" and an aria-label with the end value for screen readers. Counting uses a registered custom property and works with whole numbers only. Without scroll timelines and without init() it shows the end value. For other formats, such as 1,200 or 98.6%, use track().

Horizontal scrolling

<li data-sigmoid="fade-up" data-sigmoid-axis="inline">…</li>

data-sigmoid-axis="inline" follows the nearest horizontal scroll container.

Pinned sections

<section data-sigmoid-pin style="--sigmoid-pin-length: 300vh">
  <div> … stays in view while you scroll through the section … </div>
</section>

data-sigmoid-pin makes the section tall (--sigmoid-pin-length, default 300vh) and keeps its first child in view with position: sticky. Add story() from the JavaScript API when the content should change in steps.

Staggered lists

<ul>
  <li data-sigmoid="fade-up" style="--sigmoid-index: 0">…</li>
  <li data-sigmoid="fade-up" style="--sigmoid-index: 1">…</li>
  <li data-sigmoid="fade-up" style="--sigmoid-index: 2">…</li>
</ul>

The index shifts the default range. When you set your own --sigmoid-range, the index is ignored.

init() reads the same properties for the JavaScript fallback.

Easing variables

The stylesheet defines every curve of ease on :root, so you can use them anywhere, also for transitions:

.button { transition: transform 0.4s var(--sigmoid-ease-bouncy); }

--sigmoid-ease-linear, -out, -in-out, -standard, -sigmoid, -smooth, -bouncy, -wobbly.

With Tailwind CSS 4: ease-(--sigmoid-ease-bouncy), or register them in @theme as --ease-bouncy: var(--sigmoid-ease-bouncy).