React AnimeJS

Layout

Code

1const layoutRef = useRef<AnimeLayoutRef>(null);
2const [grid, setGrid] = useState(1);
3
4const nextGrid = () => {
5 layoutRef.current?.update(() => {
6 flushSync(() => {
7 setGrid((prev) => (prev % 4) + 1);
8 });
9 });
10}
11
12<AnimeLayout
13 ref={layoutRef}
14 duration={600}
15 ease="outExpo"
16 wrapperProps={{ 'data-grid': grid }}
17>
18 {['A', 'B', 'C', 'D'].map((char) => (
19 <AnimeLayoutItem key={char} layoutId={char}>
20 Item {char}
21 </AnimeLayoutItem>
22 ))}
23</AnimeLayout>

FLIP-based automatic and manual layout animations, supporting dynamic grid transitions, parent-child state propagation, and custom styling updates.

Live previewOpen Playground
Bento GridAdaptive Bento layout transitions
Item A
Item B
Item C
Item D
Props
NameTypeDefaultDescription
refRefObject<AnimeLayoutRef>-Imperative control ref
durationnumber500FLIP transition duration in ms
easestringoutExpoTransition easing curve
wrapperPropsHTMLAttributes-Forwarded container DOM attributes
ref.current.updatefunction-Callback to update state synchronously during layout record

Related components