Native Solid 2 fork. Original documentation and designs © WorkOS; historical posts retain their original context.
Animation
Animate Radix Primitives with CSS keyframes or the JavaScript animation library of your choice.
Adding animation to Radix Primitives should feel similar to any other component, but there are some caveats noted here in regards to exiting animations with JS animation libraries.
Animating with CSS animation
The simplest way to animate Primitives is with CSS.
You can use CSS animation to animate both mount and unmount phases. The latter is possible because the Radix Primitives will suspend unmount while your animation plays out.
Delegating unmounting for JavaScript Animation
Hidden primitive parts normally leave the native Solid tree and the DOM. Use forceMount when JavaScript controls their exit animation, and remove the parts only after that animation finishes.
This example uses the browser's Web Animations API. Reopening cancels a pending exit; disposing the component cancels its frame and animations. CSS animation remains the simpler choice when you do not need JavaScript control.