---
title: Examples
slug: wip/hBUI-examples
createdAt: 2025-08-25T07:52:00.478Z
---

# Examples

A floating bar is a fixed, non-modal interface element that keeps key information visible while users scroll. It can expand to reveal secondary content and appears as a bottom sheet on smaller touch devices.&#x20;

:::hint{type="info"}
**Floating Bar ↔ Bottom-Sheet Transition**
The transition between floating bar and bottom sheet occurs automatically based on layout rules. This behavior can not be configured.
:::

## Basic Usage

The floating bar is a non-modal component, meaning the page content remains interactive. The component provides a body slot and two header slots which are visible in their respective states: expanded and collapsed.

:::Iframe{iframeHeight="0" code="<iframe&#xA;  class=&#x22;no-border max-full-width full-height flex-grow&#x22;&#xA;  height=&#x22;700px&#x22;&#xA;  loading=&#x22;lazy&#x22;&#xA;  src=&#x22;https://codepen.io/redbulldesign/embed/ogjOzGV/c43f3dc30357446ebac322d203679fe7?default-tab=html%2Cresult&editable=true&theme-id=39967&#x22;&#xA;  title=&#x22;Embeded content from codepen.io&#x22;&#xA;></iframe>"}

:::

***

## Extended Usage

The floating bar maxes at **85vh** (including 32px top/bottom margins). On smaller viewports, the layout switches to a bottom sheet, which can expand to **95vh** with a blocking scrim at the limit. When body content exceeds the height limit, it becomes vertically scrollable.

:::Iframe{iframeHeight="0" code="<iframe&#xA;  class=&#x22;no-border max-full-width full-height flex-grow&#x22;&#xA;  height=&#x22;700px&#x22;&#xA;  loading=&#x22;lazy&#x22;&#xA;  src=&#x22;https://codepen.io/redbulldesign/embed/GgpLjyJ/bac9db229db2a0ef9538f60086ddee96?default-tab=html%2Cresult&editable=true&theme-id=39967&#x22;&#xA;  title=&#x22;Embeded content from codepen.io&#x22;&#xA;></iframe>"}

:::

***

## Non-expandable

When the `expandable` property is set to false, the floating bar stays fixed in its collapsed state. The visual cues and controls for expansion are hidden, preventing any expansion. This configuration is suited for lightweight, self-contained content where a body slot is not required.

:::Iframe{iframeHeight="0" code="<iframe&#xA;  class=&#x22;no-border max-full-width full-height flex-grow&#x22;&#xA;  height=&#x22;700px&#x22;&#xA;  loading=&#x22;lazy&#x22;&#xA;  src=&#x22;https://codepen.io/redbulldesign/embed/GgpLjxJ/efdd5416e7d302ddfaac786e622ccf81?default-tab=html%2Cresult&editable=true&theme-id=39967&#x22;&#xA;  title=&#x22;Embeded content from codepen.io&#x22;&#xA;></iframe>"}

:::

***

## Responsive Behavior

The component adapts by viewport width:&#x20;

- ≥1000px: as a floating bar
- \<1000px: as a bottom sheet&#x20;
  - ≤560px: spans 100vw
  - 561–999px: hugs content

:::Iframe{iframeHeight="0" code="<iframe&#xA;  class=&#x22;no-border max-full-width full-height flex-grow&#x22;&#xA;  height=&#x22;1000px&#x22;&#xA;  loading=&#x22;lazy&#x22;&#xA;  src=&#x22;https://codepen.io/redbulldesign/embed/MYaRjVQ/f3b360827eca67ed5fe7d5717130021c?default-tab=html%2Cresult&editable=true&theme-id=39967&#x22;&#xA;  title=&#x22;Embeded content from codepen.io&#x22;&#xA;></iframe>"}

:::

***

## Fit Content

The Floating Bar has a default fixed width of 420px. When `fit-content` is set to `true`, it hugs content until it reaches the maximum width of 560px.&#x20;

:::Iframe{iframeHeight="0" code="<iframe&#xA;  class=&#x22;no-border max-full-width full-height flex-grow&#x22;&#xA;  height=&#x22;700px&#x22;&#xA;  loading=&#x22;lazy&#x22;&#xA;  src=&#x22;https://codepen.io/redbulldesign/embed/zxvXKpL/e6a4114ae9be0ac488ad8a4428e831bf?default-tab=html%2Cresult&editable=true&theme-id=39967&#x22;&#xA;  title=&#x22;Embeded content from codepen.io&#x22;&#xA;></iframe>"}

:::


This behavior **does not apply to the bottom sheet layout**. In a bottom sheet, the component’s width automatically adjusts to its content once the screen exceeds 560px, regardless of the `fit-content` setting.

***

## Horizontal Alignment

Horizontal alignment applies only in floating bar layout: `center` by default, with options for `start`/`end` and a CSS `inline-offset` for precise positioning (RTL supported). In bottom sheet layout, the component is always centered.

:::Iframe{iframeHeight="0" code="<iframe&#xA;  class=&#x22;no-border max-full-width full-height flex-grow&#x22;&#xA;  height=&#x22;700px&#x22;&#xA;  loading=&#x22;lazy&#x22;&#xA;  src=&#x22;https://codepen.io/redbulldesign/embed/gbaywva/e6a2174e4c7fa08ece191bffc128fcad?default-tab=html%2Cresult&editable=true&theme-id=39967&#x22;&#xA;  title=&#x22;Embeded content from codepen.io&#x22;&#xA;></iframe>"}

:::

***

## Entry and Exit Trigger

The Floating Bar is always in a fixed position. Its `visibility` can be configured by consumers, normally by scroll position or position of other content within the viewport, which triggers an entry and exit animation.

:::Iframe{iframeHeight="0" code="<iframe&#xA;  class=&#x22;no-border max-full-width full-height flex-grow&#x22;&#xA;  height=&#x22;700px&#x22;&#xA;  loading=&#x22;lazy&#x22;&#xA;  src=&#x22;https://codepen.io/redbulldesign/embed/pvjBEdr/ca8583847ae00bf37da6c72251039d2d?default-tab=html%2Cresult&editable=true&theme-id=39967&#x22;&#xA;  title=&#x22;Embeded content from codepen.io&#x22;&#xA;></iframe>"}

:::

***

## Mode and Appearance

By default, the Floating bar adapts to a light mode environment and appears `light`. In a dark mode environment, we recommend changing the Floating Bars appearance to `dark`.

:::Iframe{iframeHeight="0" code="<iframe&#xA;  class=&#x22;no-border max-full-width full-height flex-grow&#x22;&#xA;  height=&#x22;700px&#x22;&#xA;  loading=&#x22;lazy&#x22;&#xA;  src=&#x22;https://codepen.io/redbulldesign/embed/empodVM/9f09ea6f47f06abc86f3b5985a9421b7?default-tab=html%2Cresult&editable=true&theme-id=39967&#x22;&#xA;  title=&#x22;Embeded content from codepen.io&#x22;&#xA;></iframe>"}

:::

## Programmatic Control

The floating bar provides `expand()` and `collapse()` methods for programmatic control. These methods enable external triggers like timers, scroll positions, or user interactions outside the component to control its expanded state. Both methods require the component to be visible and expandable to function.

:::Iframe{iframeHeight="0" code="<iframe&#xA;  class=&#x22;no-border max-full-width full-height flex-grow&#x22;&#xA;  height=&#x22;700px&#x22;&#xA;  loading=&#x22;lazy&#x22;&#xA;  src=&#x22;https://codepen.io/redbulldesign/embed/QwjeZrp/19960a5602e4c52a108763cf08809edf?default-tab=html%2Cresult&editable=true&theme-id=39967&#x22;&#xA;  title=&#x22;Embeded content from codepen.io&#x22;&#xA;></iframe>"}

:::

