Components/AutoSizer
Universal Component

AutoSizer

Component documentation for AutoSizer.

This page was migrated by AI, please review carefully

Migration is complete, but please validate against source code and manual review.

AutoSizer

Component documentation for AutoSizer.

Typical scenarios:

  • Smooth outer height transitions when switching Tabs content
  • Smooth width transitions when a Button toggles loading

Built on ResizeObserver. When images/async rendering change size, it re-measures automatically.

Basic Usage

AutoSizer height

Demo loads on client.

Width Follow (Inside Flex Containers)

When AutoSizer is a flex item and the parent stretches it with flex: 1 or width: 100%, it may look like it is not following content.

AutoSizer width in flex

Demo loads on client.

Pull-down Content Height Follow (Filters/Search)

AutoSizer height for dropdown

Demo loads on client.

Dialog Content Height Follow (Simulated)

AutoSizer height for dialog

Demo loads on client.

AutoSizer width

Demo loads on client.

Number Transition + Width Follow (NumberFlow)

AutoSizer + NumberFlow

Demo loads on client.

Smooth Text Transform + Width Follow (TextTransformer)

This example enables width + height follow and sets outer overflow-hidden to clip blur overflow.

AutoSizer + TextTransformer

Demo loads on client.

API

Props

PropTypeDefaultDescription
asstringdivDescription for as.
innerAsstringdivDescription for innerAs.
widthbooleantrueDescription for width.
heightbooleantrueDescription for height.
inlineboolean-Description for inline.
durationMsnumber200Description for durationMs.
easingstringeaseDescription for easing.
outerClassstringoverflow-hiddenouter class
innerClassstring-inner class
rounding'none' | 'round' | 'floor' | 'ceil'ceilTextValueText
immediatebooleantrueDescription for immediate.
rafBatchbooleantrueDescription for rafBatch.

Expose

NameTypeDescription
refresh()() => Promise<void>Description for refresh().
flip(action)(action: () => void | Promise<void>) => Promise<void>Text action TriggerTextSizeText(Text Tabs Text/Text)
action(fn, options?)(fn: (el: HTMLElement) => void | Promise<void>, options?: AutoSizerActionOptions | detect) => Promise<any>Text“Text”,TextTriggerText(Text demo/Text)
sizeRef<{ width: number; height: number } | null>Description for size.
Was this helpful?