API reference

Every export of @kkwaenggwari/animated-chorus with its props, types and defaults. The same names work on the web and React Native.

17 APIs

Numbers and text

MotionNumber

A number whose places roll like wheels.

PropTypeDefaultDescription
valuenumber | bigint | string—requiredThe number, or caller-formatted numeric text.
mode'replace' | 'roll''replace'replace moves each changed place one step; roll passes through the digits in between.
direction'auto' | 'digit' | 'up' | 'down''auto'auto follows the change in size so carries roll one way; digit compares each place on its own.
staggernumber45Milliseconds between changed places, from the units outward. The whole ripple is bounded.
format(value) => string | Intl.NumberFormatOptionsA function that returns the text to show, or Intl.NumberFormat options (with intl).
intlbooleanfalseUse the built-in Intl.NumberFormat. Off by default so no runtime needs Intl.
localestring | string[]Locale for intl.
prefixstringText before the number.
suffixstringText after the number.
transitionTransitionspringA timing curve { duration, easing } or a spring { tempo: 'spring', spring }. Springs keep their momentum when interrupted.
onMotionComplete(value) => voidRuns with the value once the places have settled.
Component page and workbench

MotionText

Text that animates when it changes: numeric text rolls per place, other text swaps.

PropTypeDefaultDescription
childrenReactNodeThe text to show.
aselement'span'The element to render.
transitionTransitionspringA timing curve { duration, easing } or a spring { tempo: 'spring', spring }. Springs keep their momentum when interrupted.
onMotionComplete(text) => voidRuns when the motion settles.
Component page and workbench

MotionStream

Streamed text revealed at a steady pace that catches up with bursts.

PropTypeDefaultDescription
textstring—requiredThe text so far. Growing text is revealed at a steady pace; a rewrite continues from the shared start.
speednumber90Base reveal rate in characters per second.
catchUpnumber900A backlog is revealed within about this many milliseconds by speeding up.
initialbooleanfalseAlso reveal the text present on mount (otherwise it shows at once).
effect'fade' | 'none''fade'fade fades new characters in; none shows them directly.
children(visible: string) => ReactNodeA function that receives the paced text, for example to render Markdown.
aselement'span'The element to render.
onMotionComplete(text) => voidRuns whenever the reveal catches up with text.
Component page and workbench

Content and size

MotionSwap

Content that cross-fades while the element resizes.

PropTypeDefaultDescription
valueunknownIdentity of the content; a new value swaps. Plain text children are their own identity.
childrenReactNodeThe content.
aselement'span'The element to render.
inlinebooleanas === 'span'true sizes to the content (labels, icons); false fills the parent width and animates height.
align'start' | 'center' | 'end''center'Where the content sits while the size changes.
effect'fade' | 'up' | 'down' | 'scale''fade'How content enters and leaves: up rises, down falls, scale grows.
transitionTransitionspringA timing curve { duration, easing } or a spring { tempo: 'spring', spring }. Springs keep their momentum when interrupted.
onMotionComplete(value) => voidRuns when the motion settles.
Component page and workbench

MotionHeight

Animates height to its content: collapse, expand and content changes.

PropTypeDefaultDescription
openbooleantruefalse collapses to zero height; the content stays mounted but hidden and inert.
childrenReactNodeThe content.
aselement'div'The element to render.
transitionTransitionspringA timing curve { duration, easing } or a spring { tempo: 'spring', spring }. Springs keep their momentum when interrupted.
onMotionComplete(open) => voidRuns with open once the height has settled.
Component page and workbench

MotionPresence

Keeps content mounted while it animates in and out.

PropTypeDefaultDescription
presentboolean—requiredShow or hide the content. Change this instead of unmounting.
enterPose{ opacity: 1, translateY: 0 }The pose at rest.
exitPose{ opacity: 0, translateY: -12 }The pose the content leaves with and enters from.
aselement'div'The element to render.
transitionTransitionspringA timing curve { duration, easing } or a spring { tempo: 'spring', spring }. Springs keep their momentum when interrupted.
onExitComplete() => voidRuns after the content has left and been removed.
Component page and workbench

Selection and paging

MotionHighlight

Items from data with one highlight that travels to the selected item.

PropTypeDefaultDescription
itemsreadonly T[]—requiredYour data array.
valuekey | null—requiredKey of the highlighted item; null hides the highlight.
onValueChange(key, item) => voidRuns with the key and the item when an item is pressed.
getKey(item) => string | numberitem.idReturns a unique, stable key for an item. Defaults to item.id, or the item itself for strings and numbers.
renderItem(item, { selected, index }) => ReactNodeitem.labelDraws an item; receives whether it is selected.
hoverbooleanfalseFollow the pointer over items and return to value on leave (web).
itemAselement'button'The element for each item.
itemClassNamestringClass for each item element; itemStyle sets its inline style.
highlightClassNamestringClass for the highlight; highlightStyle sets its inline style.
transitionTransitionspringA timing curve { duration, easing } or a spring { tempo: 'spring', spring }. Springs keep their momentum when interrupted.
Component page and workbench

MotionPager

Swipeable pages from data.

PropTypeDefaultDescription
itemsreadonly T[]—requiredYour data array.
indexnumberThe page shown. Leave it out to let the pager keep its own.
defaultIndexnumber0Starting page when index is not controlled.
onIndexChange(index, item) => voidRuns with the index and item as soon as a swipe, key or wheel gesture settles.
getKey(item) => string | numberitem.idReturns a unique, stable key for an item. Defaults to item.id, or the item itself for strings and numbers.
renderItem(item, { index, active }) => ReactNodeitem.labelDraws a page; receives its index and whether it is active.
gapnumber0Space between pages in pixels.
itemClassNamestringClass for each item element; itemStyle sets its inline style.
transitionTransitionspringA timing curve { duration, easing } or a spring { tempo: 'spring', spring }. Springs keep their momentum when interrupted.
Component page and workbench

Lists

MotionList

A keyed list from data that animates only what changed.

PropTypeDefaultDescription
itemsreadonly T[]—requiredYour data array.
getKey(item) => string | numberitem.idReturns a unique, stable key for an item. Defaults to item.id, or the item itself for strings and numbers.
renderItem(item, index) => ReactNodeitem.labelDraws an item.
aselement'div'The element to render.
itemAselement'li' | 'div'The element for each item.
itemClassNamestringClass for each item element; itemStyle sets its inline style.
effect'rise' | 'fade' | 'scale' | 'slide''rise'How items enter and leave.
distancenumber16Travel of rise and slide in pixels.
staggernumber40Milliseconds between entering items.
order'forward' | 'reverse''forward'Direction of the stagger.
presentbooleantruefalse animates every item out while keeping the layout; true brings them back.
initialbooleantruePlay the entrance when the list mounts.
playKeystring | numberChanging it replays the entrance.
transitionTransitionspringTransition for entering and leaving items.
layoutTransitionTransitionspringTransition for items gliding to new positions.
Component page and workbench

MotionReorder

Drag to reorder a list or a grid, with keyboard moves.

PropTypeDefaultDescription
itemsreadonly T[]The items, when you control the order.
defaultItemsreadonly T[][]Starting items, when the component keeps the order.
onItemsChange(items, { reason, key }) => voidRuns with the new order and whether it came from a drag, a drop or the keyboard.
getKey(item) => string | numberitemReturns a unique key for an item. Defaults to the item itself.
renderItem(item, { index, dragging }) => ReactNodeitem.labelDraws an item; receives its index and whether it is being dragged.
reorder'live' | 'drop''live'live moves other items while dragging; drop waits for the drop.
layout'list' | 'grid''grid'list or grid.
columnsnumber3Columns in a grid.
gapnumber12Space between items in pixels.
disabledbooleanfalseTurns dragging off.
durationnumber260Milliseconds for items moving out of the way.
itemClassNamestringClass for each item element; itemStyle sets its inline style.
Component page and workbench

Gestures

MotionSwipe

A row that reveals actions with a horizontal swipe and can be swiped away.

PropTypeDefaultDescription
childrenReactNodeThe row content.
startActionsReactNodeRevealed at the inline start when the row is dragged toward the end.
endActionsReactNodeRevealed at the inline end when the row is dragged toward the start.
dismiss'start' | 'end' | 'both'Sides where a long swipe or a throw removes the row.
onDismiss(side) => voidRuns after the row slid out and collapsed; remove the item from your data here.
onOpenChange(side | null) => voidRuns with the open side, or null when the row closes.
disabledbooleanfalseTurns swiping off.
contentClassNamestringClass for the row content; contentStyle sets its inline style.
transitionTransitionspringA timing curve { duration, easing } or a spring { tempo: 'spring', spring }. Springs keep their momentum when interrupted.
Component page and workbench

MotionHold

Press and hold to confirm; releasing early rewinds.

PropTypeDefaultDescription
childrenReactNodeThe button label.
onConfirm() => voidRuns once the hold completes.
durationnumber1200Milliseconds the press must be held.
disabledbooleanfalseTurns the button off.
fillClassNamestringClass for the growing fill; fillStyle sets its inline style.
Component page and workbench

Overlays

MotionSheet

A bottom sheet, top sheet or side drawer with detents.

PropTypeDefaultDescription
openbooleanfalseWhether the sheet is shown.
onOpenChange(open) => voidRuns with false when the sheet is dragged, tapped or escaped closed.
detents(number | 'content')[]['content']Resting sizes: a fraction of the screen, pixels, or 'content'.
detentnumberControlled detent index.
defaultDetentnumber0Detent index used when opening without detent.
onDetentChange(index) => voidRuns with the index of the detent the sheet settles on.
side'bottom' | 'top' | 'start' | 'end''bottom'The edge the sheet comes from.
modalbooleantrueAdds a backdrop, keeps focus inside and makes the page inert.
dismissiblebooleantrueDragging past the smallest detent, the backdrop and Escape close it.
backdropClassNamestringClass for the backdrop; backdropStyle sets its inline style.
transitionTransitionspringA timing curve { duration, easing } or a spring { tempo: 'spring', spring }. Springs keep their momentum when interrupted.
Component page and workbench

MotionZoom

An image that zooms from where it is to fill the screen.

PropTypeDefaultDescription
srcstringThe image shown in place.
zoomSrcstringA larger image shown once it has loaded; keep the same aspect ratio.
marginnumber24Space kept around the zoomed image in pixels.
disabledbooleanfalseTurns zooming off.
onZoomChange(zoomed) => voidRuns with true when zoomed and false when closed.
backdropStyleCSSPropertiesInline style for the backdrop.
transitionTransitionspringA timing curve { duration, easing } or a spring { tempo: 'spring', spring }. Springs keep their momentum when interrupted.
Component page and workbench

Progress

ProgressBar

A controlled progress line with an indeterminate state.

PropTypeDefaultDescription
valuenumber | nullProgress from 0 to max; null is indeterminate.
maxnumber100The value that means complete.
colorstring'currentColor'Fill color.
trackColorstring'#e7ece9'Track color.
thicknessnumber8Line thickness in pixels.
direction'ltr' | 'rtl''ltr'Fill from the left (ltr) or from the right (rtl).
transitionTransitionspringA timing curve { duration, easing } or a spring { tempo: 'spring', spring }. Springs keep their momentum when interrupted.
Component page and workbench

ProgressRing

A controlled progress ring with an indeterminate state.

PropTypeDefaultDescription
valuenumber | nullProgress from 0 to max; null is indeterminate.
maxnumber100The value that means complete.
sizenumber96Diameter in pixels.
thicknessnumber8Ring thickness in pixels.
colorstring'currentColor'Arc color.
trackColorstring'#e7ece9'Track color.
childrenReactNodeA label shown in the middle.
transitionTransitionspringA timing curve { duration, easing } or a spring { tempo: 'spring', spring }. Springs keep their momentum when interrupted.
Component page and workbench

Transitions

motionTokens

Ready-made values for any transition prop.

PropTypeDefaultDescription
duration{ instant, fast, normal, slow }0 · 140 · 280 · 520Durations in milliseconds.
easing{ ease, easeOut, expoOut, backOut }TransitionTiming transitions with a duration and a named curve.
spring{ quick, basic, gentle, bouncy }TransitionSpring transitions, from quick and firm to gentle and bouncy.
Transitions
App.jsx
// Web and React Native: the same import.
import { MotionNumber, MotionList } from '@kkwaenggwari/animated-chorus';

export function Score({ points, players }) {
  return (
    <>
      <MotionNumber value={points} />
      <MotionList items={players} renderItem={(player) => player.name} />
    </>
  );
}

Search

Type to search the documentation.