Baike.dev
All toolsOnline toolsAI codingTrendingOpen sourceNewsSubmit
Log in
< Back to tools
A

alpine-floating-ui

> 编程语言
Open source

Add Floating UI functionality to Alpine 3.x components.

100 stars0 likes2 views
WebsiteGitHub

About

Add Floating UI functionality to Alpine 3.x components.

Alpine Floating UI

Add Floating UI functionality to Alpine 3.x components.

This package only supports Alpine ^3.x.

About

This plugin adds a $float magic and an x-float directive to Alpine, with modifiers for Floating UI functionality.

Installation

CDN

Include the following `

bash

### NPM

```bash
npm install @awcodes/alpine-floating-ui

This plugin has the option to use x-trap, but you must also include the Alpine Focus plugin as well to make use of it.

javascript
import Alpine from "alpinejs";
import Focus from "@alpinejs/focus"; // optional unless you want to use x-trap
import AlpineFloatingUI from "@awcodes/alpine-floating-ui";

Alpine.plugin(Focus); // optional unless you want to use x-trap
Alpine.plugin(AlpineFloatingUI);

window.Alpine = Alpine;
window.Alpine.start();

CSS

See the Floating UI Tutorial for infomation about styling.

Usage

$float Magic

To create a Floating UI component, use the $float magic on the trigger element and apply an x-ref to your 'panel'. Don't forget to have x-data on the root element of your component.

xml

x-float Directive

To create a floating UI component with x-float, add the directive to your floating element with an x-ref to name the name. You can then trigger the panel with a click event using $refs to target the panel.

Available methods on the trigger are toggle, open, and close.

To use the middleware with x-float simply chain on the middleware you need to use.

xml

Floating UI configuration

The first argument of $float should be an object.

This object currently accepts the 'position', 'flip', 'offset', 'shift', 'arrow', and 'hide' middleware for Floating UI. See the Floating UI Tutorial for infomation about these options.

Default options are:

javascript
{
    placement: 'bottom',
    middleware: [autoPlacement()],
}

With $float Magic

To use the default options for each middleware pass an empty object as the value.

xml

With x-float Directive

All settings should be configured within the expression of the x-float directive with the exception of placement which should be used directly on the directive itself. See https://floating-ui.com/docs/computePosition#placement placement options.

xml

  

With x-float Directive

xml

  

Styling the arrow (this is just an example, you are free to style it anyway you choose):

css
.arrow {
  position: absolute;
  background-color: inherit;
  width: 8px;
  height: 8px;
  transform: rotate(45deg);
}

X-Trap

The second argument that can be passed to $float is an object of plugin options for each float-ui element.

With $float Magic

xml

With x-float Directive

xml

Versioning

This projects follow the Semantic Versioning guidelines.

License

Copyright (c) 2022 Adam Weston and contributors

Licensed under the MIT license, see LICENSE.md for details.

Issues· 0 open

View all issuesOpen on GitHub

No open issues yet, or sync has not completed.

> Tags

JavaScript

No comments yet. Be the first to share.

> Details

PublishedAug 1, 2026
UpdatedSep 18, 2026
Category编程语言
PricingOpen source

> Related tools

T
TypeScript
JavaScript 的超集,为前端与全栈提供静态类型
P
Python
通用编程语言,广泛用于 Web、数据与 AI
G
Go
Google 推出的简洁高效系统语言