Popover - Skeleton

  1. integrations
  2. popover
  3. react

Popover

Learn how to integrate dynamic and interactive popover interfaces.

Floating UI React

Floating UI →

Floating UI React →

Floating UI provides primitives for creating tooltips, popovers, dropdown menus, hover cards, modal dialogs, select menus, comboboxes, and more. Instead of providing pre-built components, this guide will introduce the fundamentals of Floating UI React. This provides an open-ended solution for creating your own popover features and components for any form factor - while pairing with Skeleton’s design system and components.


Learn the Basics

If this is your first time using Floating UI, start here:

Imports

Floating UI React exposes all required Floating UI middleware, types, etc.

import { useFloating } from '@floating-ui/react';

Making Elements Float

You’ll need a dedicated CSS class to apply common styles to all floating elements. Apply the following in your global stylesheet. We’ll use the following class convention for all Skeleton examples.

.floating {
width: max-content;
position: absolute;
top: 0;
left: 0;
}

Z-Index Stacking

Please be aware that Floating UI does not take an opinionated stance on z-index stacking. This means that if a floating element is occluded by another element in the z-axis, you must handle this directly.

Middleware

Make sure you’re familiar all available Floating UI Middleware, which provides modules for customizing the look and feel of popovers.


Examples

Floating UI React provides an extensive set of headless React examples. We’ll use these as the foundation for at the following set of examples that fully integrate Skeleton. See the official Floating UI React documentation for a complete API Reference.

Popover

Triggers an anchored popover when you click the trigger element.

Tooltip

Triggers an anchored popover when you hover the trigger element.

Combobox

Triggers an anchored popover list on search. Includes autocomplete with automatic selection.

Generates any form of modal or dialog that require a user’s immediate attention.


Additional Tips

Reusable Components

See tips for convert the primitive examples above into reusable components in your local project.

Accessibility

When implementing popovers, make sure to account for accessibility and keyboard interactions. Floating UI React provides a number of hooks and components to help facilitate all requirements.

ARIA APG Patterns →


Native Browser APIs

Skeleton will always favor native browser APIs over third-party libraries such as Floating UI Svelte. The following is a list of current and upcoming incoming APIs we will aim to support in the future, but are not quite standardized cross-browser yet.