UI.MD

Floating Bar

A bar that floats at the bottom of the screen over a blurred band, holding a Nav or a few actions. Its inset, height and corner come from tokens and follow the size of what it holds.

Installation

$
npx shadcn@latest add https://ui.mattdowney.com/r/floating-bar.json

Usage

import { FloatingBar, floatingBarReserve } from "@/components/ui/floating-bar"

Examples

Default

Holds a Nav. The page puts floatingBarReserve() on its outer element, so its last content scrolls clear of the bar. Scroll the preview to see the band blur what passes under it.

Top

side="top" mirrors it: the inset reads the top safe area, the band fades downward, and the page reserves room at its top.

Actions for a selection

Any controls can go inside. Set size to the controls' size so the bar's height and corner follow them.

3 selected

API Reference

PropTypeDefaultDescription
sideFloatingBar"top" | "bottom""bottom"The screen edge the bar floats on.
sizeFloatingBar"sm" | "default" | "lg""default"The size of the controls inside. The bar's height and corner follow it.
classNameFloatingBarstring-Merged onto the bar's surface, not the fixed layer around it.
floatingBarReserveexport({ side?, size? }) => string-A padding class for the page under the bar, on the bar's side: the inset, the bar, one more gutter and the safe area.
sideFloatingBar"top" | "bottom" = "bottom"The screen edge the bar floats on.
sizeFloatingBar"sm" | "default" | "lg" = "default"The size of the controls inside. The bar's height and corner follow it.
classNameFloatingBarstringMerged onto the bar's surface, not the fixed layer around it.
floatingBarReserveexport({ side?, size? }) => stringA padding class for the page under the bar, on the bar's side: the inset, the bar, one more gutter and the safe area.