Animate
Motion primitives: animated borders, scroll progress and entrance transitions.
Installation
bun add @xerobi/ui
import { AnimateBorder, AnimateCountUp, AnimateLogoRotate, AnimateLogoZoom, AnimateText, MotionContainer, MotionLazy, MotionViewport, ScrollProgress } from "@xerobi/ui/animate"This component is client-side. In Astro, hydrate it with a client directive.
API reference
AnimateBorder
| Prop | Type | Description |
|---|---|---|
| duration | number | Seconds for one lap. |
| slotProps | { primaryBorder?: BorderStyleProps | undefined; secondaryBorder?: BorderStyleProps | undefined; outlineColor?: string | undefined; svgSettings?: { rx?: strin... |
AnimateCountUp
| Prop | Type | Description |
|---|---|---|
| to* | number | |
| from | number | |
| toFixed | number | |
| duration | number | |
| unit | "b" | "k" | "m" | (string & {}) | |
| once | boolean | |
| amount | number | "some" | "all" | |
| render | "symbol" | "object" | "style" | "div" | "a" | "abbr" | "address" | "area" | "article" | "aside" | "audio" | "b" | "base" | "bdi" | "bdo" | "big" | "blockquot... |
AnimateLogoRotate
| Prop | Type | Description |
|---|---|---|
| logo | string | number | bigint | boolean | ReactElement<unknown, string | JSXElementConstructor<any>> | Iterable<ReactNode> | ReactPortal | Promise<AwaitedReactNode> | |
| slotProps | { logo?: LogoProps | undefined; } |
AnimateLogoZoom
| Prop | Type | Description |
|---|---|---|
| logo | string | number | bigint | boolean | ReactElement<unknown, string | JSXElementConstructor<any>> | Iterable<ReactNode> | ReactPortal | Promise<AwaitedReactNode> | |
| slotProps | { logo?: LogoProps | undefined; } |
AnimateText
| Prop | Type | Description |
|---|---|---|
| variants | Variants | |
| repeatDelayMs | number | |
| textContent* | string | string[] | |
| once | boolean | |
| amount | number | "some" | "all" | |
| render | "symbol" | "object" | "style" | "div" | "a" | "abbr" | "address" | "area" | "article" | "aside" | "audio" | "b" | "base" | "bdi" | "bdo" | "big" | "blockquot... |
MotionContainer
| Prop | Type | Description |
|---|---|---|
| ref | ((instance: HTMLDivElement | null) => void | (() => VoidOrUndefinedOnly)) | RefObject<HTMLDivElement | null> | |
| animate | (boolean | TargetAndTransition | VariantLabels | LegacyAnimationControls) & boolean | Values to animate to, variant label(s), or `LegacyAnimationControls`. ```jsx // As values <motion.div animate={{ opacity: 1 }} /> // As variant <motion.div animate="visible" variants={variants} /> // Multiple variants <motion.div animate={["visible", "active"]} variants={variants} /> // LegacyAnimationControls <motion.div animate={animation} /> ``` |
| action | boolean |
MotionLazy
| Prop | Type | Description |
|---|---|---|
| children* | string | number | bigint | boolean | ReactElement<unknown, string | JSXElementConstructor<any>> | Iterable<ReactNode> | ReactPortal | Promise<AwaitedReactNode> |
MotionViewport
| Prop | Type | Description |
|---|---|---|
| ref | ((instance: HTMLDivElement | null) => void | (() => VoidOrUndefinedOnly)) | RefObject<HTMLDivElement | null> | |
| disableAnimate | boolean |
ScrollProgress
| Prop | Type | Description |
|---|---|---|
| progress* | MotionValue<number> | From `useScrollProgress()`. |
| variant* | "linear" | "circular" | |
| size | number | |
| thickness | number | |
| portal | boolean | |
| whenScroll | "x" | "y" | Axis being tracked; matters for right-to-left layouts. |
| color | "info" | "success" | "warning" | "secondary" | "inherit" | "primary" | "error" | |
| className | string | |
| wrapperClassName | string |
Hooks
useScrollProgress: Scroll progress of the page, or of the element you attach `elementRef` to.