|
1 | 1 | <p align="center">
|
2 |
| - <img height="300" src="https://github.com/atomiks/floating-ui/blob/main/website/assets/logo.png" alt="Floating UI"> |
| 2 | + <img height="560" src="https://github.com/floating-ui/floating-ui/blob/master/website/assets/floating-ui-banner.png" alt="Floating UI"> |
3 | 3 | <p>
|
4 |
| - |
5 |
| -> **Popper is now Floating UI! For Popper v2, visit [its dedicated branch.](https://github.com/floating-ui/popper-core/tree/v2.x)** |
6 | 4 |
|
7 |
| -[](https://rollingversions.com/floating-ui/floating-ui) |
| 5 | +> **Popper is now Floating UI! For Popper v2, visit |
| 6 | +> [its dedicated branch.](https://github.com/floating-ui/floating-ui/tree/v2.x)** |
8 | 7 |
|
9 |
| -[Website](https://floating-ui.com) |
| 8 | +[Floating UI](https://floating-ui.com) is a low-level library for creating |
| 9 | +"floating" elements like tooltips, popovers, dropdowns, menus, and more. |
10 | 10 |
|
11 |
| -Floating UI is a low-level library for positioning "floating" elements like |
12 |
| -tooltips, popovers, dropdowns, menus and more while intelligently keeping them |
13 |
| -in view. |
| 11 | +The library provides two key functionalities: |
14 | 12 |
|
15 |
| -Challenges arise when positioning floating elements as they get taken out of the |
16 |
| -normal layout flow of a document, leading to issues with clipping and overflow, |
17 |
| -which is where this library can help! |
| 13 | +- **Positioning primitives**: Ensure your floating element is positioned |
| 14 | + optimally in the viewport for the user (placement, overflow |
| 15 | + prevention/clipping detection, and more). |
| 16 | +- **Interaction primitives**: Add accessible interactions that power floating |
| 17 | + elements (event listeners, dismissing, ARIA attributes, focus trapping, list |
| 18 | + navigation, and more). |
18 | 19 |
|
19 |
| -- **Tiny**: 600-byte core with highly modular architecture for tree-shaking |
20 |
| -- **Low-level**: Granular control over positioning behavior |
21 |
| -- **Pure**: Predictable and side-effect free |
22 |
| -- **Extensible**: Powerful middleware system |
23 |
| -- **Platform-agnostic**: Runs on any JavaScript environment which provides |
24 |
| - measurement APIs, including the web and React Native |
| 20 | +The positioning engine features a tiny 600-byte core with strong tree-shaking |
| 21 | +support, is extensible through custom middleware, and can support any platform. |
25 | 22 |
|
26 |
| -## Installation |
| 23 | +## Install |
27 | 24 |
|
28 |
| -To use it on the web: |
| 25 | +Choose the package that suits you. |
| 26 | + |
| 27 | +### Vanilla DOM positioning engine |
| 28 | + |
| 29 | +Use with vanilla JavaScript or a non-React framework |
| 30 | +([view tutorial](https://floating-ui.com/docs/tutorial)). |
29 | 31 |
|
30 | 32 | ```shell
|
31 | 33 | npm install @floating-ui/dom
|
32 | 34 | ```
|
33 | 35 |
|
| 36 | +### React DOM positioning engine |
| 37 | + |
| 38 | +Use with React DOM ([view docs](https://floating-ui.com/docs/react-dom)). |
| 39 | + |
34 | 40 | ```shell
|
35 |
| -yarn add @floating-ui/dom |
| 41 | +npm install @floating-ui/react-dom |
| 42 | +``` |
| 43 | + |
| 44 | +### React DOM interactions and positioning engine |
| 45 | + |
| 46 | +Primitive hooks and components, in addition to the positioning engine, to use |
| 47 | +with React DOM |
| 48 | +([view docs](https://floating-ui.com/docs/react-dom-interactions)). |
| 49 | + |
| 50 | +```shell |
| 51 | +npm install @floating-ui/react-dom-interactions |
| 52 | +``` |
| 53 | + |
| 54 | +### React Native positioning engine |
| 55 | + |
| 56 | +Use with React Native ([view docs](https://floating-ui.com/docs/react-native)). |
| 57 | + |
| 58 | +```shell |
| 59 | +npm install @floating-ui/react-native |
| 60 | +``` |
| 61 | + |
| 62 | +### Canvas or other platforms |
| 63 | + |
| 64 | +Learn about creating a [Platform](https://floating-ui.com/docs/platform). |
| 65 | + |
| 66 | +```shell |
| 67 | +npm install @floating-ui/core |
36 | 68 | ```
|
37 | 69 |
|
38 | 70 | ## Quick start
|
@@ -62,33 +94,20 @@ computePosition(referenceElement, floatingElement, {
|
62 | 94 |
|
63 | 95 | ## Development and production builds
|
64 | 96 |
|
65 |
| -Floating UI is published with default, development, and |
66 |
| -production builds, using Node's support for |
| 97 | +Floating UI is published with default, development, and production builds, using |
| 98 | +Node's support for |
67 | 99 | [export conditions](https://nodejs.org/api/packages.html#packages_conditional_exports).
|
68 | 100 |
|
69 |
| -- `"default"`: uses `process.env.NODE_ENV`, in which |
70 |
| - your bundler handles the env variable, dead code elimination, |
71 |
| - and minification |
| 101 | +- `"default"`: uses `process.env.NODE_ENV`, in which your bundler handles the |
| 102 | + env variable, dead code elimination, and minification |
72 | 103 | - `"production"`: minified with no debug logging
|
73 | 104 | - `"development"`: unminified with debug logging
|
74 | 105 |
|
75 |
| -If you're using a bundler like webpack, Vite, or Parcel, this is |
76 |
| -handled for you **automatically**. |
| 106 | +If you're using a bundler like webpack, Vite, or Parcel, this is handled for you |
| 107 | +**automatically**. |
77 | 108 |
|
78 |
| -If this is not handled, you must opt into one of the builds in |
79 |
| -tools that support export conditions. This is done differently |
80 |
| -for each tool. |
81 |
| - |
82 |
| -## React |
83 |
| - |
84 |
| -- [React DOM](https://floating-ui.com/docs/react-dom) |
85 |
| -- [React Native](https://floating-ui.com/docs/react-native) (\*experimental) |
86 |
| - |
87 |
| -## Components |
88 |
| - |
89 |
| -Right now, Floating UI focuses on positioning floating elements, but a package |
90 |
| -that exposes higher-level primitives for building these elements more easily is |
91 |
| -in development. |
| 109 | +If this is not handled, you must opt into one of the builds in tools that |
| 110 | +support export conditions. This is done differently for each tool. |
92 | 111 |
|
93 | 112 | ## Contributing
|
94 | 113 |
|
@@ -119,6 +138,13 @@ as much as possible.
|
119 | 138 | `npm -w website run dev` in the root will launch the website at
|
120 | 139 | `localhost:3000`.
|
121 | 140 |
|
| 141 | +## Credits |
| 142 | + |
| 143 | +The floating shapes in the banner image are made by the amazing artists |
| 144 | +[@artstar3d](https://figma.com/@artstar3d), |
| 145 | +[@killnicole](https://figma.com/@killnicole) and |
| 146 | +[@liiiiiiii](https://www.figma.com/@liiiiiii) on Figma — check out their work! |
| 147 | + |
122 | 148 | ## License
|
123 | 149 |
|
124 | 150 | MIT
|
0 commit comments