Getting Started
Floating UI Svelte is a library that helps you create floating elements such as tooltips, popovers, dropdowns, and more.
Support
Supports Svelte v5 projects created with SvelteKit, Vite/Svelte, or Astro.
Install
To install Floating UI, use your package manager of choice.
Usage
Making elements "float
The following styles must be applied to any and all floating elements. We recommend using a class as shown below. Note that Floating UI does not take an opinionated stance on z-index stacking.
Caveats
SSR
When SSR is enabled and the floating element is visible upon pageload it will first be positioned in the top left of your screen until the position is calculated. This is usually not desirable. To prevent this, you can utilize the isPositioned prop returned from the useFloating hook: