Float

A positioning component that floats its content at a specified position relative to its parent. Useful for badges, indicators, and notification dots.

Anatomy

<script>
  import { Float } from "@saas-ui/svelte/layout/float";
</script>

<div class="relative">
  <Avatar />
  <Float placement="top-end">
    <Badge>3</Badge>
  </Float>
</div>

Examples

Basic Accessibility

Basic float positioning with default top-end placement for badge or indicator overlays.

Offsets Accessibility

Use offset, offsetX, or offsetY props to fine-tune the floating element position.

Placements Accessibility

All available placements: top-start, top-center, top-end, middle-start, middle-center, middle-end, bottom-start, bottom-center, bottom-end.

With Avatar Accessibility

Common use case showing a notification badge floating on an avatar component.

Props

Prop Type Default Description
placement top-start | top-center | top-end | bottom-start | bottom-center | bottom-end | middle-start | middle-center | middle-end top-end The placement of the indicator.
offsetX text - The x offset of the indicator.
offsetY text - The y offset of the indicator.
offset text - The x and y offset of the indicator.
children any - The content to be rendered inside the component.
class text - Additional CSS classes to apply.