Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/floating-ui/svelte-popper

🍿🔗Official Svelte wrapper for Popper - the positioning library
https://github.com/floating-ui/svelte-popper

dropdowns popovers popperjs positioning svelte svelte-component tooltips

Last synced: 2 months ago
JSON representation

🍿🔗Official Svelte wrapper for Popper - the positioning library

Awesome Lists containing this project

README

        

# @popperjs/svelte

Use Popper in your Svelte projects.

### Installation

```
yarn add @popperjs/svelte
# or
npm i @popperjs/svelte
```

### Usage

```svelte

import Popper from "@popperjs/svelte";

// super-simple CSS Object to string serializer
const css = obj =>
Object.entries(obj || {})
.map(x => x.join(":"))
.join(";");

// DOM references to the interested elements
let referenceElement;
let popperElement;
let arrowElement;

// Popper options, reactive to update when arrowElement is set
$: popperOptions = {
modifiers: [
{ name: "offset", options: { offset: [0, 5] } },
{ name: "arrow", options: { element: arrowElement } }
]
};

// bound variables where Popper will store styles and attributes
let styles = {};
let attributes = {};

console.log(styles);

/* for some example styles, see `dev/App.svelte` */

Reference Element


Popper Element

```