Getting Started
Floating UI Svelte is a library that helps you create floating elements such as tooltips, popovers, dropdowns, and more.
Requirements
Supports projects created using Svelte v5.
Install
Install Floating UI Svelte using your package manager of choice.
Usage
Floating UI Features
Floating UI Svelte exposes all Floating UI middleware, types, etc. You do not need to install @floating-ui/dom
seperately.
Making elements "float"
At minimum, the following styles must be applied to ensure floating elements do not disrupt the flow of the document. This can be handled using a single reusable CSS class.
Z-Index Stacking
Please be aware that Floating UI does not take an opinionated stance on z-index stacking.
Caveats
Server-Side Rendering (SSR)
When SSR is enabled and the floating element is visible upon page load it will first be positioned in the top left of your screen. It will remain until the position is calculated. To prevent this, you may utilize the isPositioned prop returned from the useFloating hook: