Usage
Returns a handle to pass to a component whose size changes, such as TreeList or Collapsible. When that component changes size, it and the content before and after it inside containerRef animate together on one shared motion role. Inside an absolutely positioned, fixed, stuck sticky or top-layer ancestor of the component, only the content after it moves. Fixed and stuck sticky elements stay put, the glide never scrolls the area, and Reduce Motion is respected. It applies under every pointer, a mouse included. Without the handle a component keeps its jump: the content around it takes its place at once. The content that glides may mix Astryx components and your own elements; none of it opts in.
tsimport {useAnimatedLayout} from '@astryxdesign/core/hooks'
Best practices
| Guidance | Practices |
|---|---|
| Do | Create one handle per scroll container or panel and pass the same handle to every component in it whose size changes. |
| Do | Pass the ref you already give ScrollableArea as containerRef; ScrollableArea does not register itself. |
| Don't | Wrap the content around a disclosure in an extra element to make it move; the content the glide moves inside the container needs no wrapper. |
| Don't | Animate height yourself alongside it; the glide moves content with a compositor translate and never animates height. |
Parameters
| Param | Type | Description |
|---|---|---|
options.containerRefrequired | RefObject<HTMLElement | null> | The area the glide stays inside: the ref you already give your scroll container or panel. A ScrollableArea ref reaches its native scroll viewport, so pass that. |
Returns
| Field | Type | Description |
|---|---|---|
| animatedLayout | An opaque handle with no public members. Pass it to the animatedLayout prop of a component whose size changes, such as TreeList or Collapsible. |
Use with shadcn
Already using the shadcn registry workflow? Install the real Astryx package and a local public re-export. Component implementation source stays in Astryx.
This install URL expires with the draft preview.bashnpx shadcn@4.19.0 add https://astryx-cexfj3typ-fbopensource.vercel.app/shadcn/hooks/use-animated-layout.json