Skip to Content
Neshel-UI
Animations (experimental)Effects

Press & Microinteractions

The 11 effects P01–P11: purpose, API, options, examples, reduced motion and cost.

Experimental and not on npm

@neshel-ui/animations is a private package (0.0.0). It cannot be installed, and its API may change before a first publication. These pages document what exists in the repository.

Press effects respond to real activation, pointer or keyboard, and never change what the control does. <Press> accepts one preset or a list. Triggered effects (burst, shake, nudge) play when their trigger value changes after mounting; the initial value never plays. ToggleMorph and CheckboxDraw are decorative visuals for inside your own labelled control. Disabled elements never react.

P01 · Press scale

pressScale shrinks the control while it is held: scale (0.96, between 0.5 and 1) and spring. Under reduced motion half of the amplitude remains, without the spring, because it confirms the press.

Import
@neshel-ui/animations/press
API
pressScale, Press
Stylesheet
none needed
Reduced motion
reduced — a smaller signal remains because it conveys state
Performance
Transform and opacity, one write per frame through the shared scheduler; no layout work per frame.
Preview: P01
Preview theme: P01
p01.tsx
"use client";
import { Press, pressScale } from "@neshel-ui/animations/press";
import { Button } from "@neshel-ui/components";

export default function P01Example() {
  return (
    <Press preset={pressScale} options={{ scale: 0.92 }} asChild>
      <Button>Press me</Button>
    </Press>
  );
}
Options: PressScaleOptions

PressScaleOptions

P01 — Press scale: shrink while pressed, spring back on release (pointer, Space/Enter).

PressScaleOptions
PropTypeDefaultDescription
disabledboolean—Turn the effect off. Disabled elements (:disabled, aria-disabled="true") never react.
reducedMotionReducedMotion"user"Reduced-motion policy (default "user").
scalenumber—Scale while pressed (0.5–1, default 0.96). Reduced motion keeps half the amplitude, without spring.
springSpringOptions | SpringPreset——

P02 · Ripple

ripple expands a circle from the point of contact, or from the centre with the keyboard: color, opacity (0.22) and duration (550 ms). It draws on a child layer owned by the package.

Import
@neshel-ui/animations/press
API
ripple, Press
Stylesheet
@neshel-ui/animations/press.css
Reduced motion
fade — opacity only, no travel
Performance
Web Animations on a layer owned by the package; nothing runs per frame in JavaScript.
Preview: P02
Preview theme: P02
p02.tsx
"use client";
import "@neshel-ui/animations/press.css";
import { Press, ripple } from "@neshel-ui/animations/press";
import { Button } from "@neshel-ui/components";

export default function P02Example() {
  return (
    <Press preset={ripple} asChild>
      <Button size="lg">Ripple from the pointer</Button>
    </Press>
  );
}
Options: RippleOptions

RippleOptions

P02 — Ripple: an expanding circle from the press point on a clipped, owned layer.

RippleOptions
PropTypeDefaultDescription
colorstringcurrentColorRipple colour (default currentColor).
disabledboolean—Turn the effect off. Disabled elements (:disabled, aria-disabled="true") never react.
durationnumber—Expansion duration in ms (100–3000, default 550).
opacitynumber—Ripple opacity (0–1, default 0.22).
reducedMotionReducedMotion"user"Reduced-motion policy (default "user").

P03 · Tap bounce

tapBounce answers a completed tap with a spring bounce: strength (0.3) and spring. It plays after the activation, so it never delays the action.

Import
@neshel-ui/animations/press
API
tapBounce, Press
Stylesheet
none needed
Reduced motion
off — no motion at all
Performance
Transform and opacity, one write per frame through the shared scheduler; no layout work per frame.
Preview: P03
Preview theme: P03
p03.tsx
"use client";
import { Press, tapBounce } from "@neshel-ui/animations/press";
import { Button } from "@neshel-ui/components";

export default function P03Example() {
  return (
    <Press preset={tapBounce} options={{ strength: 0.5 }} asChild>
      <Button variant="outline">Tap me</Button>
    </Press>
  );
}
Options: TapBounceOptions

TapBounceOptions

P03 — Tap bounce: a springy squash after each activation (click, including keyboard).

TapBounceOptions
PropTypeDefaultDescription
disabledboolean—Turn the effect off. Disabled elements (:disabled, aria-disabled="true") never react.
reducedMotionReducedMotion"user"Reduced-motion policy (default "user").
springSpringOptions | SpringPreset"bouncy"Spring (default "bouncy").
strengthnumber—Impulse strength (0–1, default 0.3).

P04 · Toggle morph

<ToggleMorph> draws the track and thumb of a switch and stretches the thumb as checked changes (stretch 0.3). It has no semantics: put it inside a role="switch" button with a name. For a complete control use the Components Switch.

Import
@neshel-ui/animations/press
API
ToggleMorph, toggleMorph
Stylesheet
@neshel-ui/animations/press.css
Reduced motion
instant — the end state appears at once
Performance
The package stylesheet renders it on layers owned by the package; your element gets no transition or animation.
Preview: P04
Preview theme: P04
p04.tsx
"use client";
import "@neshel-ui/animations/press.css";
import { ToggleMorph } from "@neshel-ui/animations/press";
import { useState } from "react";

export default function P04Example() {
  const [on, setOn] = useState(false);
  return (
    <button
      type="button"
      role="switch"
      aria-checked={on}
      aria-label="Notifications"
      onClick={() => setOn(!on)}
      className="rounded-full p-1"
    >
      <ToggleMorph checked={on} />
    </button>
  );
}
Options: ToggleMorphOptions

ToggleMorphOptions

ToggleMorphOptions
PropTypeDefaultDescription
checked(required)boolean—Current state (mirror your switch's checked / aria-checked).
reducedMotionReducedMotion——
springSpringOptions | SpringPreset"snappy"Thumb spring (default "snappy").
stretchnumber—Peak stretch of the thumb mid-travel (0–0.6, default 0.3).

P05 · Checkbox draw

<CheckboxDraw> draws the mark of a checkbox with checked and indeterminate (duration 240 ms). The native input keeps the semantics and the keyboard; hide it visually, not from assistive technology.

Import
@neshel-ui/animations/press
API
CheckboxDraw, checkboxDraw
Stylesheet
@neshel-ui/animations/press.css
Reduced motion
instant — the end state appears at once
Performance
The package stylesheet renders it on layers owned by the package; your element gets no transition or animation.
Preview: P05
Preview theme: P05
p05.tsx
"use client";
import "@neshel-ui/animations/press.css";
import { CheckboxDraw } from "@neshel-ui/animations/press";
import { useState } from "react";

export default function P05Example() {
  const [done, setDone] = useState(false);
  return (
    <label className="flex w-fit items-center gap-2 rounded p-1 has-focus-visible:outline-2">
      <input
        type="checkbox"
        className="sr-only"
        checked={done}
        onChange={(event) => setDone(event.currentTarget.checked)}
      />
      <CheckboxDraw checked={done} /> Send me the summary
    </label>
  );
}
Options: CheckboxDrawOptions

CheckboxDrawOptions

CheckboxDrawOptions
PropTypeDefaultDescription
checked(required)boolean | "indeterminate"—Current state (mirror your checkbox).
durationnumber | "fast" | "normal" | "slow" | "deliberate"240Draw duration in ms or preset (default 240).
easingEasing | EasingPreset——
reducedMotionReducedMotion——

P06 · Burst

burst throws particles from the element when trigger changes: count (10), distance (34 px), size and colors. Celebrate rarely; announce the result with text.

Import
@neshel-ui/animations/press
API
burst, Press
Stylesheet
@neshel-ui/animations/press.css
Reduced motion
static — the decoration or content stays still
Performance
Web Animations on a layer owned by the package; nothing runs per frame in JavaScript.
Preview: P06
Preview theme: P06
p06.tsx
"use client";
import "@neshel-ui/animations/press.css";
import { burst, Press } from "@neshel-ui/animations/press";
import { Button } from "@neshel-ui/components";
import { useState } from "react";

export default function P06Example() {
  const [likes, setLikes] = useState(0);
  return (
    <Press preset={burst} options={{ trigger: likes, count: 14 }} asChild>
      <Button variant="outline" onClick={() => setLikes(likes + 1)}>
        Like ({likes})
      </Button>
    </Press>
  );
}
Options: BurstOptions

BurstOptions

P06 — Burst: particles radiate from the centre on an owned layer when trigger changes.

BurstOptions
PropTypeDefaultDescription
colorsreadonly string[]—Particle colours, cycled (default theme-friendly warm colours).
countnumber—Number of particles (3–24, default 10).
disabledboolean—Turn the effect off. Disabled elements (:disabled, aria-disabled="true") never react.
distancenumber—Travel distance in px (8–160, default 34).
durationnumber—Duration in ms (200–3000, default 650).
reducedMotionReducedMotion"user"Reduced-motion policy (default "user").
sizenumber—Particle size in px (2–16, default 6).
triggerstring | number | boolean—Change this value (a counter, a timestamp) to play the effect. The initial value never plays.

P07 · Shake

shake moves the element sideways when trigger changes: distance (8 px), cycles (4) and duration (420 ms). The error must also be text with role="alert" or aria-describedby; the shake is never the only signal.

Import
@neshel-ui/animations/press
API
shake, Press
Stylesheet
none needed
Reduced motion
reduced — a smaller signal remains because it conveys state
Performance
Transform and opacity, one write per frame through the shared scheduler; no layout work per frame.
Preview: P07
Preview theme: P07

Enter your code

p07.tsx
"use client";
import { Press, shake } from "@neshel-ui/animations/press";
import { Button } from "@neshel-ui/components";
import { useState } from "react";

export default function P07Example() {
  const [errors, setErrors] = useState(0);
  return (
    <div className="grid justify-items-start gap-3">
      <Press
        preset={shake}
        options={{ trigger: errors }}
        className="rounded-xl border border-neshel-border bg-neshel-surface p-6 text-neshel-surface-foreground"
      >
        <p role="alert">{errors ? `Wrong code (attempt ${errors})` : "Enter your code"}</p>
      </Press>
      <Button onClick={() => setErrors(errors + 1)}>Submit a wrong code</Button>
    </div>
  );
}
Options: ShakeOptions

ShakeOptions

P07 — Shake (error): a short damped horizontal shake. Never the only error signal.

ShakeOptions
PropTypeDefaultDescription
cyclesnumber—Oscillations (1–8, default 4).
disabledboolean—Turn the effect off. Disabled elements (:disabled, aria-disabled="true") never react.
distancenumber—Amplitude in px (1–30, default 8). Reduced motion: a third, fewer cycles.
durationnumber—Duration in ms (100–2000, default 420).
reducedMotionReducedMotion"user"Reduced-motion policy (default "user").
triggerstring | number | boolean—Change this value (a counter, a timestamp) to play the effect. The initial value never plays.

P08 · Nudge

nudge rotates the element briefly to attract attention: angle (6°), cycles (3) and at most three repeats separated by interval. It plays on trigger changes, never in an endless loop.

Import
@neshel-ui/animations/press
API
nudge, Press
Stylesheet
none needed
Reduced motion
off — no motion at all
Performance
Transform and opacity, one write per frame through the shared scheduler; no layout work per frame.
Preview: P08
Preview theme: P08
Inbox (0)
p08.tsx
"use client";
import { nudge, Press } from "@neshel-ui/animations/press";
import { Button } from "@neshel-ui/components";
import { useState } from "react";

export default function P08Example() {
  const [count, setCount] = useState(0);
  return (
    <div className="flex items-center gap-4">
      <Press
        preset={nudge}
        options={{ trigger: count, angle: 10 }}
        className="rounded-xl border border-neshel-border bg-neshel-surface p-6 text-neshel-surface-foreground"
      >
        Inbox ({count})
      </Press>
      <Button variant="outline" onClick={() => setCount(count + 1)}>
        New message
      </Button>
    </div>
  );
}
Options: NudgeOptions

NudgeOptions

P08 — Nudge / attention jiggle: a short rotation wiggle, optionally repeated a few times.

NudgeOptions
PropTypeDefaultDescription
anglenumber—Amplitude in degrees (1–20, default 6).
cyclesnumber—Oscillations (1–6, default 3).
disabledboolean—Turn the effect off. Disabled elements (:disabled, aria-disabled="true") never react.
durationnumber—Duration in ms (100–2000, default 600).
intervalnumber—Pause between plays in ms (1000–10000, default 2500).
reducedMotionReducedMotion"user"Reduced-motion policy (default "user").
repeatnumber—Extra plays after the first (0–3, default 0); never more than 4 plays in total (WCAG 2.2.2).
triggerstring | number | boolean—Change this value (a counter, a timestamp) to play the effect. The initial value never plays.

P09 · Number tick

<NumberTick> counts from the previous value to the new one. locale, formatOptions or your own format produce the text; the accessible value does not change on every frame, and live opts into an announcement.

Import
@neshel-ui/animations/press
API
NumberTick, numberTick
Stylesheet
none needed
Reduced motion
instant — the end state appears at once
Performance
Updates the text of one decorative node per frame; the accessible value is not updated per frame.
Preview: P09
Preview theme: P09
1,280
p09.tsx
"use client";
import { NumberTick } from "@neshel-ui/animations/press";
import { Button } from "@neshel-ui/components";
import { useState } from "react";

export default function P09Example() {
  const [value, setValue] = useState(1280);
  return (
    <div className="flex items-center gap-4">
      <NumberTick value={value} locale="en-US" className="text-3xl font-semibold" />
      <Button variant="outline" onClick={() => setValue(value + 1375)}>
        Add sales
      </Button>
    </div>
  );
}
Options: NumberTickOptions

NumberTickOptions

NumberTickOptions
PropTypeDefaultDescription
durationnumber | "fast" | "normal" | "slow" | "deliberate"600Count duration in ms or preset (default 600).
easingEasing | EasingPreset——
format(value: number) => stringIntl.NumberFormat(locale, formatOptions)Formats the displayed number (default Intl.NumberFormat(locale, formatOptions)).
formatOptionsIntl.NumberFormatOptions——
localestring"en-US"Locale of the default formatter (default "en-US", explicit so server and client agree).
reducedMotionReducedMotion——
value(required)number——

P10 · Content swap

<ContentSwap> swaps its children for confirm while active is true — "Copy link" and "Copied" — in one stacked cell, so the width does not jump. live announces the confirmation.

Import
@neshel-ui/animations/press
API
ContentSwap, contentSwap
Stylesheet
@neshel-ui/animations/press.css
Reduced motion
fade — opacity only, no travel
Performance
The package stylesheet renders it on layers owned by the package; your element gets no transition or animation.
Preview: P10
Preview theme: P10
p10.tsx
"use client";
import "@neshel-ui/animations/press.css";
import { ContentSwap } from "@neshel-ui/animations/press";
import { Button } from "@neshel-ui/components";
import { useState } from "react";

export default function P10Example() {
  const [copied, setCopied] = useState(false);
  return (
    <Button variant="outline" onClick={() => setCopied(!copied)}>
      <ContentSwap active={copied} confirm="Copied">
        Copy link
      </ContentSwap>
    </Button>
  );
}
Options: ContentSwapOptions

ContentSwapOptions

ContentSwapOptions
PropTypeDefaultDescription
reducedMotionReducedMotion——

P11 · Long press

<LongPress> calls onLongPress once after holding for duration (600 ms), with a progress fill; releasing early cancels it. Holding Space or Enter works too, or a single press with keyboard: "press". Offer another path for destructive actions.

Import
@neshel-ui/animations/press
API
LongPress, longPress
Stylesheet
@neshel-ui/animations/press.css
Reduced motion
reduced — a smaller signal remains because it conveys state
Performance
Web Animations on a layer owned by the package; nothing runs per frame in JavaScript.
Preview: P11
Preview theme: P11
Not archived
p11.tsx
"use client";
import "@neshel-ui/animations/press.css";
import { LongPress } from "@neshel-ui/animations/press";
import { Button } from "@neshel-ui/components";
import { useState } from "react";

export default function P11Example() {
  const [archived, setArchived] = useState(false);
  return (
    <div className="flex items-center gap-4">
      <LongPress onLongPress={() => setArchived(true)} duration={800} asChild>
        <Button variant="outline">Hold to archive</Button>
      </LongPress>
      <output>{archived ? "Archived" : "Not archived"}</output>
    </div>
  );
}
Options: LongPressOptions

LongPressOptions

LongPressOptions
PropTypeDefaultDescription
disabledboolean——
durationnumber—Hold time in ms (200–5000, default 600).
keyboard"hold" | "press"—Keyboard: hold Space/Enter for the duration ("hold", default) or activate on one press ("press").
moveTolerancenumber—px of pointer movement that cancels (2–50, default 10).
onCancel() => void—Called when a started press ends without completing.
onLongPress(source: "pointer" | "keyboard") => void—Called once per completed long press.
pointerTypesreadonly ("mouse" | "pen" | "touch")[]—Pointer types that may long-press (default mouse, pen and touch).
reducedMotionReducedMotion"user"Reduced motion keeps a linear, non-vestibular fill (the progress conveys state). Default "user".
Edit on GitHub

On this page