![Create React App Officially Deprecated Amid React 19 Compatibility Issues](https://cdn.sanity.io/images/cgdhsj6q/production/04fa08cf844d798abc0e1a6391c129363cc7e2ab-1024x1024.webp?w=400&fit=max&auto=format)
Security News
Create React App Officially Deprecated Amid React 19 Compatibility Issues
Create React App is officially deprecated due to React 19 issues and lack of maintenance—developers should switch to Vite or other modern alternatives.
@floating-ui/react
Advanced tools
The @floating-ui/react package is a library for creating floating elements that can be positioned next to a given reference element. It is commonly used for tooltips, popovers, dropdowns, and similar components. The library provides a set of hooks and utilities to manage the positioning and behavior of these floating elements in a React application.
Positioning Tooltips
This code demonstrates how to use @floating-ui/react to position a tooltip above a reference button, with an offset and the ability to flip based on available space.
import {useFloating, offset, flip} from '@floating-ui/react';
function Tooltip() {
const {x, y, reference, floating, strategy} = useFloating({
placement: 'top',
middleware: [offset(10), flip()]
});
return (
<>
<button ref={reference}>Reference Element</button>
<div ref={floating} style={{
position: strategy,
top: y ?? '',
left: x ?? ''
}}>Floating Content</div>
</>
);
}
Creating Popovers
This example shows how to create a popover component positioned to the right of a reference element, including shifting to stay within the viewport and an arrow pointing to the reference.
import {useFloating, shift, arrow} from '@floating-ui/react';
function Popover({referenceElement}) {
const {x, y, floating, strategy, middlewareData} = useFloating({
placement: 'right-start',
middleware: [shift(), arrow({element: arrowElement})]
});
return (
<div ref={floating} style={{
position: strategy,
top: y ?? '',
left: x ?? ''
}}>
Popover Content
<div ref={arrowElement} style={{
position: 'absolute',
[middlewareData.arrow.x != null ? 'left' : 'top']: middlewareData.arrow.x ?? middlewareData.arrow.y
}} />
</div>
);
}
Popper.js is a predecessor to @floating-ui/react, offering similar functionality for positioning floating elements. While Popper.js provides a robust API for managing poppers, @floating-ui/react offers a more modern, hook-based approach tailored for React applications, potentially offering a more streamlined integration.
Tippy.js is a tooltip and popover library that builds on top of Popper.js. It provides a high-level abstraction for creating and managing tooltips, popovers, and dropdowns. Compared to @floating-ui/react, Tippy.js includes more out-of-the-box styling and interaction options, making it a good choice for users looking for a more complete solution with less setup.
This is the library to use Floating UI with React.
FAQs
Floating UI for React
The npm package @floating-ui/react receives a total of 3,372,856 weekly downloads. As such, @floating-ui/react popularity was classified as popular.
We found that @floating-ui/react demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 2 open source maintainers collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
Create React App is officially deprecated due to React 19 issues and lack of maintenance—developers should switch to Vite or other modern alternatives.
Security News
Oracle seeks to dismiss fraud claims in the JavaScript trademark dispute, delaying the case and avoiding questions about its right to the name.
Security News
The Linux Foundation is warning open source developers that compliance with global sanctions is mandatory, highlighting legal risks and restrictions on contributions.