Floating Action Button

Fixed-position action button for primary actions. Install Floating Action Button from the VLLNT UI registry with the shadcn CLI.

Report a bug

Fixed-position action button for primary actions. Part of the utility family in VLLNT UI, it ships as a machine-readable registry entry — copy the source directly into your app with the shadcn CLI and own it, no runtime dependency on a component library.

Preview

Switch between light and dark to inspect the embedded Storybook preview.

Installation

Add Floating Action Button to your project with the shadcn CLI. The source lands in your codebase, ready to adapt:

pnpm dlx shadcn@latest add https://ui.vllnt.ai/r/floating-action-button.json

Source

"use client"; import { memo } from "react"; import type { ReactNode } from "react"; import { cn } from "../../lib/utils"; export type FloatingActionButtonProps = { "aria-label": string; children: ReactNode; className?: string; onClick: () => void; position?: "bottom-left" | "bottom-right"; }; function FloatingActionButtonImpl({ "aria-label": ariaLabel, children, className, onClick, position = "bottom-right", }: FloatingActionButtonProps): React.ReactNode { return ( <button aria-label={ariaLabel} className={cn( "fixed z-40 flex size-12 items-center justify-center rounded-full", "bg-primary text-primary-foreground shadow-lg", "transition-transform hover:scale-110", "focus:outline-none focus:ring-2 focus:ring-primary focus:ring-offset-2", position === "bottom-right" && "bottom-20 right-4 sm:bottom-4", position === "bottom-left" && "bottom-20 left-4 sm:bottom-4", className, )} onClick={onClick} type="button" > {children} </button> ); } export const FloatingActionButton = memo(FloatingActionButtonImpl); FloatingActionButton.displayName = "FloatingActionButton";

Stories

Explore every variant and state in the interactive Storybook:

Preview

Switch between light and dark to inspect the embedded Storybook preview.

Dependencies

  • @vllnt/ui@^0.3.0