floating-ui-vue-skilld
/floating-ui-vue-skilld
Dokumentuje użycie Floating UI dla Vue (@floating-ui/vue 2.0.1): useFloating, arrow, floatingStyles, autoUpdate, middleware, elementy wirtualne i migracja z v1 do v2.
- Autor
- skilld-dev ↗
- Repozytorium
- vue-ecosystem-skills ↗
- Licencja
- MIT
- Ostatnia zmiana repozytorium
- 11.10.2026
Ocena i bezpieczeństwo
- Pliki w paczce
- 3
- Skrypty
- 0
- Komentarze HTML
- 0
- Adresy URL w SKILL.md
- 7
Brak sygnałów. Repozytorium zmienione 11.10.2026, bez odwołań do wycofanych modeli i API.
MIT, otwarta: można używać i zmieniać, z zachowaniem informacji o autorze.
Co robi i kiedy
Dokumentuje użycie Floating UI dla Vue (@floating-ui/vue 2.0.1): useFloating, arrow, floatingStyles, autoUpdate, middleware, elementy wirtualne i migracja z v1 do v2.
Wyzwalacze z opisu
Oryginalny opis (EN)
Floating UI for Vue (@floating-ui/vue@2.0.1). ALWAYS use when writing code importing \"@floating-ui/vue\" or using useFloating, arrow, floatingStyles, or autoUpdate. Consult for middleware setup, anchoring, virtual elements, and v1 to v2 migration. Vue 3.3+ only.
Jak działa
- Version limits
- Quick start
- API changes since 1.x
- Best practices
- Common tasks
- Package exports
Podgląd SKILL.md
---
name: floating-ui-vue-skilld
description: "Floating UI for Vue (@floating-ui/vue@2.0.1). ALWAYS use when writing code importing \"@floating-ui/vue\" or using useFloating, arrow, floatingStyles, or autoUpdate. Consult for middleware setup, anchoring, virtual elements, and v1 to v2 migration. Vue 3.3+ only."
license: MIT
---
# @floating-ui/vue 2.0.1
Vue 3 composable for anchor positioning. `useFloating()` computes `x`/`y` coordinates that place a floating element (tooltip, popover, menu) next to a reference element.
## Version limits
- Vue `>=3.3.0` only (peer dependency, `package.json:58`). v2.0.0 dropped the `vue-demi` layer, ending Vue 2 and Vue <3.3 support.
- Vue 2 or Vue <3.3 projects must stay on `npm install @floating-ui/vue@1` (https://floating-ui.com/docs/vue).
- Runtime dependencies: `@floating-ui/dom@^1.8.0`, `@floating-ui/utils@^0.2.12` (`package.json:46-49`).
- TypeScript with `exactOptionalPropertyTypes`: supported since v2.0.1 (optional properties are typed `T | undefined`, `dist/floating-ui.vue.d.ts:198-224`).
## Quick start
```vue
<script setup>
import {ref} from 'vue';
import {useFloating, offset, flip, shift, autoUpdate} from '@floating-ui/vue';
const reference = ref(null);
const floating = ref(null);
const open = ref(false);
const {floatingStyles, isPositioned} = useFloating(reference, floating, {
open,
middleware: [offset(10), flip(), shift()],
whileElementsMounted: autoUpdate,
});
</script>
<template>
<button ref="reference" @click="open = !open">Button</button>
<div v-if="open" ref="floating" :style="floatingStyles">Tooltip</div>
</template>
```
Default placement is `bottom`; positioning uses `transform` by default (https://floating-ui.com/docs/vue).
## API changes since 1.x
- BREAKING (2.0.0): `vue-demi` removed. Vue 2 and Vue <3.3 no longer supported. No other breaking API changes; `useFloating`, `arrow`, and all re-exports keep their 1.1.x signatures (https://github.com/floating-ui/floating-ui/releases/tag/@floating-ui/vue@2.0.0).
- FIX (2.0.1): optional `useFloating` options accept explicit `undefined` under `exactOptionalPropertyTypes` (https://github.com/floating-ui/floating-ui/releases/tag/@floating-ui/vue@2.0.1).
- Unchanged behaviors carried from 1.x: `x`/`y` default to `0` (not `null`); `floatingStyles` returns ready-to-bind positioning styles; options accept refs and getters (`MaybeReadonlyRefOrGetter`) since 1.1.0 (verified in `dist/floating-ui.vue.d.ts:193-225`, `dist/floating-ui.vue.mjs:83-84`).
## Best practices
- Pass `whileElementsMounted: autoUpdate` so the floating element stays anchored during scroll, resize, and layout changes (`dist/floating-ui.vue.mjs:146-156`; https://floating-ui.com/docs/vue).
- When wrapping `autoUpdate` to pass options, always return the cleanup function (`dist/floating-ui.vue.mjs:140-145`):
```ts
useFloating(reference, floating, {
whileElementsMounted(...args) {
return autoUpdate(...args, {animationFrame: true});
},
});
```
- Use `v-if` for the floating element when using `whileElementsMounted`. With `v-show`, skip `whileElementsMounted` and manage `autoUpdate` manually, or listeners leak on hidden elements (https://floating-ui.com/docs/vue).
- Pass an `open` ref and gate side effects on `isPositioned`; positioning resolves in a microtask, so the element sits at (0, 0) until then. `isPositioned` stays `false` while `open` is `false` (`dist/floating-ui.vue.mjs:137`, `dist/floating-ui.vue.mjs:157-161`):
```ts
const {isPositioned} = useFloating(reference, floating, {open});
watch(isPositioned, (positioned) => {
if (positioned) inputRef.value?.focus();
});
```
- Pass refs or getters (`() => props.placement`) to `open`, `placement`, `strategy`, `middleware`, `transform` options for reactivity; they are watched with `flush: 'sync'` (`dist/floating-ui.vue.mjs:162-164`).
- Pass component template refs directly. Components are unwrapped via `$el`; a component that renders a comment node resolves to `null` and positioning safely no-ops (`dist/floating-ui.vue.mjs:6-15`).
- Keep the default `transform: true` and animate an inner wrapper element if you need CSS transform animations; the outer positioned node keeps `translate()` positioning (https://floating-ui.com/docs/vue).
- Use `arrow({element: arrowRef})` with a template ref. It no-ops (returns `{}`) until the arrow element mounts; read `middlewareData.arrow?.x/.y` for placement (`dist/floating-ui.vue.mjs:27-34`).
## Common tasks
- Arrow positioning example and full option defaults: [API reference](./references/api.md).
- Upgrading from 1.x or pinning for Vue 2: [Migration guide](./references/migration.md).
## Package exports
`useFloating`, `arrow`, plus re-exports from `@floating-ui/dom`: `autoPlacement`, `autoUpdate`, `computePosition`, `detectOverflow`, `flip`, `getOverflowAncestors`, `hide`, `inline`, `limitShift`, `offset`, `platform`, `shift`, `size` (`dist/floating-ui.vue.mjs:2`). Import middleware from `@floating-ui/vue`, not `@floating-ui/dom`, to keep the Vue-aware `arrow` behavior.
Pliki w paczce (3)
- SKILL.md 5 KB
- references/api.md 6 KB
- references/migration.md 3 KB
Wersje
W bazie nie ma innych skilli o nazwie floating-ui-vue-skilld.
Identyczna treść występuje jeszcze w 1 innych folderach na GitHubie. Tu pokazujemy jedną, najlepiej ocenioną kopię.
Migawka bazy z 28.10.2026 · wersja paczki 823e4927dc0f (skrót SHA-256 całej paczki)
Pobrania w ostatnich 30 dniach: 0 · ranking
Zgłoś problem z tym skillem: szkodliwa treść, błędny opis albo prośba autora o usunięcie.
Podobne skille
- 100tanstack-vue-query-skilld
Pomaga pisać, debugować i poprawiać kod @tanstack/vue-query, czyli hooki do cache i synchronizacji danych w Vue. - 100vue-router-skilld
Pomaga pisać kod vue-router: trasy oparte na plikach, typowane trasy, data loaders i debugowanie routera Vue. - 100vue
Pokazuje, jak używać custom elements w Vue, z wymaganą konfiguracją kompilatora Vue 2 i 3, Nuxt i integracji. - 100solid-floating-ui
Buduje w SolidJS elementy nakładkowe, takie jak podpowiedzi, popovery, okna dialogowe i listy wyboru, z poprawną reaktywnością. - 95vue
Renderuje interfejsy Vue 3 ze specyfikacji JSON przez @json-render/vue, w tym rejestry komponentów i specyfikacje generowane przez AI. - 86vue
Pomaga w Vue: komponentach, zarządzaniu stanem Pinia, Vue Router i budowie aplikacji Vue 3.