Skip to content

motion/size

import { … } from 'zidane-ui'ui/src/motion/size.tsx

Crossfade (scale): spinner → check → x
Crossfade (text)
Running tests…
Presence
new
RollingText in SmoothWidth
HeldWidth
1s
SwapIcon

Components#

HeldWidthComponent#

Renders a trailing slot whose width grows to fit its content and never shrinks while holdKey stays the same, so a label that changes often does not make its neighbours move. When holdKey changes, it eases to the new content's width once the old content has faded.

TypeScript
function HeldWidth(props: HeldWidthProps): Element
Parameters
NameTypeDescription
propsHeldWidthProps

Component props.

Element
HeldWidth props
NameTypeDescription
childrenReactNode

The slot's content. It sits against the right edge.

className?string

Extra classes on the outer element.

holdKeystring

Identifies the mode of the slot. The held width is released when it changes.

style?CSSProperties

Inline styles on the root element, merged after the component's own.

ui/src/motion/size.tsx:137

SmoothHeightComponent#

A block whose height eases when its content is swapped, instead of jumping: the old height is held in the frame the new content lands, then eases to the new one (settle), then lets go. Nothing collapses to be measured (the content keeps its own height inside), so a transcript following its bottom follows the ease frame by frame. At once with motion off or reduced.

TypeScript
function SmoothHeight(props: SmoothHeightProps): Element
Parameters
NameTypeDescription
propsSmoothHeightProps

Component props.

Element
SmoothHeight props
NameTypeDescription
childrenReactNode

The content.

className?string

Extra classes on the outer element.

swapKeystring

What the content is: when it changes (live lines giving way to a result), the height eases from the old content's to the new one's. Between changes the height follows the content at once (it animates itself).

ui/src/motion/size.tsx:218

SmoothWidthComponent#

Animates its own width to its content's, so a chip that gains a segment or a digit grows smoothly instead of jumping. The content is measured with a ResizeObserver; the first size applies without a transition.

TypeScript
function SmoothWidth(props: SmoothWidthProps): Element
Parameters
NameTypeDescription
propsSmoothWidthProps

Component props.

Element
SmoothWidth props
NameTypeDescription
childrenReactNode

The content to size to.

className?string

Extra classes on the outer element.

style?CSSProperties

Inline styles on the root element, merged after the component's own.

ui/src/motion/size.tsx:28

Interfaces#

HeldWidthPropsInterface#

Props for HeldWidth.

TypeScript
interface HeldWidthProps
HeldWidthProps properties
NameTypeDescription
childrenReactNode

The slot's content. It sits against the right edge.

className?string

Extra classes on the outer element.

holdKeystring

Identifies the mode of the slot. The held width is released when it changes.

style?CSSProperties

Inline styles on the root element, merged after the component's own.

ui/src/motion/size.tsx:119

SmoothHeightPropsInterface#

Props for SmoothHeight.

TypeScript
interface SmoothHeightProps
SmoothHeightProps properties
NameTypeDescription
childrenReactNode

The content.

className?string

Extra classes on the outer element.

swapKeystring

What the content is: when it changes (live lines giving way to a result), the height eases from the old content's to the new one's. Between changes the height follows the content at once (it animates itself).

ui/src/motion/size.tsx:198

SmoothWidthPropsInterface#

Props for SmoothWidth.

TypeScript
interface SmoothWidthProps
SmoothWidthProps properties
NameTypeDescription
childrenReactNode

The content to size to.

className?string

Extra classes on the outer element.

style?CSSProperties

Inline styles on the root element, merged after the component's own.

ui/src/motion/size.tsx:12