Floating Action Button

VdFab surfaces a primary action as a round, elevated button. Pick a variant, size, position, or the extended pill; add an actions slot to turn it into a self-managing speed-dial menu (it owns its own open state, Escape, and outside-click handling).

Sizes
<button class="vd-fab vd-fab-sm" aria-label="Small">...</button>   <!-- 40px -->
<button class="vd-fab" aria-label="Default">...</button>            <!-- 56px -->
<button class="vd-fab vd-fab-lg" aria-label="Large">...</button>   <!-- 72px -->
Extended (with label)
<button class="vd-fab vd-fab-extended" aria-label="Create new item">
  <i class="ph ph-plus"></i>
  <span>New</span>
</button>

<button class="vd-fab vd-fab-extended vd-fab-success">
  <i class="ph ph-check"></i><span>Save</span>
</button>
Color Variants
<button class="vd-fab"><i class="ph ph-plus"></i></button>
<button class="vd-fab vd-fab-secondary"><i class="ph ph-pencil-simple"></i></button>
<button class="vd-fab vd-fab-success"><i class="ph ph-check"></i></button>
<button class="vd-fab vd-fab-danger"><i class="ph ph-trash"></i></button>
<button class="vd-fab vd-fab-glass"><i class="ph ph-star"></i></button>
Position Variants

In production the position prop pins the FAB (position: fixed) to the viewport. This preview scopes live <VdFab> buttons to the box below.

<!-- The position prop pins a FAB (position: fixed) to a viewport spot -->
<VdFab position="bottom-right" aria-label="Compose">
  <i class="ph ph-pencil-simple"></i>
</VdFab>

<!-- Other positions: bottom-left | top-right | top-left | center -->
<VdFab position="top-left" aria-label="Back"><i class="ph ph-arrow-up-left"></i></VdFab>
Speed Dial Menu

Click the FAB to toggle the speed dial. The component tracks its own open state, reflects it via aria-expanded, and closes on Esc or an outside click — no page-level state required.

<VdFab aria-label="Toggle actions">
  <i class="ph ph-plus"></i>
  <template #actions>
    <VdFab size="sm" variant="success" aria-label="Upload">
      <i class="ph ph-upload-simple"></i>
    </VdFab>
    <VdFab size="sm" aria-label="Photo">
      <i class="ph ph-image"></i>
    </VdFab>
    <VdFab size="sm" variant="danger" aria-label="Record">
      <i class="ph ph-microphone"></i>
    </VdFab>
  </template>
</VdFab>
API Reference

Usage

<script setup lang="ts">
import { VdFab } from "@vanduo-oss/vd3";
</script>

<template>
  <!-- Pinned single-action FAB -->
  <VdFab position="bottom-right" aria-label="Compose" @click="onCompose">
    <i class="ph ph-pencil-simple"></i>
  </VdFab>

  <!-- Extended (pill) FAB with a visible label -->
  <VdFab extended label="New item" variant="success">
    <i class="ph ph-plus"></i>
  </VdFab>
</template>

Component API

Prop / event / slotDescription
:variant'primary' | 'secondary' | 'success' | 'danger' | 'error' (default 'primary'; 'error' is an alias of 'danger').
:size'sm' | 'md' | 'lg' — diameter (default 'md').
:extendedPill-shaped variant that renders `label` beside the icon slot.
:glassGlass-styled surface (`.vd-fab-glass`).
:position'bottom-right' | 'bottom-left' | 'top-right' | 'top-left' | 'center' — pins the FAB (position: fixed) to the viewport.
:labelVisible text for the extended (pill) mode; also the fallback aria-label.
:aria-labelAccessible name (takes priority over `label`).
@clickMouseEvent — emitted on activation. In menu mode it also toggles the speed dial.
default slotThe icon / button content.
actions slotSpeed-dial action buttons. Its presence switches on the .vd-fab-menu wrapper; Escape and outside-click close it.

Modifier classes

ClassDescription
.vd-fabBase FAB. Round, elevated. 56 px by default.
.vd-fab-sm / .vd-fab-lgSize variants — 40 px / 72 px.
.vd-fab-secondary / -success / -dangerColor variants — the base .vd-fab is already primary.
.vd-fab-extendedWider pill-shaped variant with an icon + label.
.vd-fab-glassGlass-styled variant (uses `--vd-glass-*` tokens).
.vd-fab-fixed / -top-left / -top-right / -bottom-left / -centerFixed-position modifiers that pin the FAB to a viewport corner (or center).
.vd-fab-menuSpeed-dial wrapper (relative, column layout).
.vd-fab-actionsContainer for the action buttons; revealed when .vd-fab-menu has .is-open.

CSS Variables

VariableDefaultDescription
--vd-fab-size3.5rem (56 px)Default diameter
--vd-fab-size-sm2.5rem (40 px)Small diameter
--vd-fab-size-lg4.5rem (72 px)Large diameter
--vd-fab-menu-gap0.8125remGap between speed-dial buttons
--vd-fab-shadow0 3px 8px rgba(0,0,0,.25), 0 1px 3px rgba(0,0,0,.15)Elevation shadow
--vd-fab-z-index1030Stacking above page content
--vd-fab-offset1.3125remDistance from viewport edges
Accessibility
  • Always set :aria-label (or :label) on an icon-only FAB; it has no accessible name otherwise.
  • In menu mode the trigger carries aria-expanded reflecting its open state.
  • FABs are real <button> elements — focus, keyboard activation, and form integration work natively.
  • FABs respect prefers-reduced-motion: the hover lift and speed-dial stagger are skipped when set.