Get Updates

Floating Action Panel

A versatile floating action panel component with support for multiple triggers and modes.

Christer Hagen

Written by Christer Hagen

The Floating Action Panel component provides a flexible way to create floating action menus and forms. Perfect for contextual actions, quick access menus, and note-taking interfaces.

Installation

Examples

Usage

Basic Usage

import { Plus } from "lucide-react"
import {
  FloatingActionPanelRoot,
  FloatingActionPanelTrigger,
  FloatingActionPanelContent,
  FloatingActionPanelButton,
} from "@/components/prismui/floating-action-panel"
 
export default function Example() {
  return (
    <FloatingActionPanelRoot>
      {({ mode }) => (
        <>
          <FloatingActionPanelTrigger title="Quick Actions" mode="actions">
            Actions
          </FloatingActionPanelTrigger>
          <FloatingActionPanelContent>
            <div className="space-y-1 p-2">
              <FloatingActionPanelButton onClick={() => console.log("New")}>
                <Plus className="h-4 w-4" />
                New Item
              </FloatingActionPanelButton>
            </div>
          </FloatingActionPanelContent>
        </>
      )}
    </FloatingActionPanelRoot>
  )
}

Multiple Modes

<FloatingActionPanelRoot>
  {({ mode }) => (
    <>
      <FloatingActionPanelTrigger title="Actions" mode="actions">
        Actions
      </FloatingActionPanelTrigger>
      <FloatingActionPanelTrigger title="Add Note" mode="note">
        Add Note
      </FloatingActionPanelTrigger>
      <FloatingActionPanelContent>
        {mode === "actions" ? (
          <div className="space-y-1 p-2">
            {/* Action buttons */}
          </div>
        ) : (
          <FloatingActionPanelForm onSubmit={handleNoteSubmit}>
            <FloatingActionPanelTextarea className="h-24" />
            {/* Submit button */}
          </FloatingActionPanelForm>
        )}
      </FloatingActionPanelContent>
    </>
  )}
</FloatingActionPanelRoot>

Components

FloatingActionPanelRoot

The root component that manages the state and context for the floating panel.

<FloatingActionPanelRoot>
  {({ mode }) => (
    // Children components
  )}
</FloatingActionPanelRoot>

FloatingActionPanelTrigger

The button that triggers the floating panel.

<FloatingActionPanelTrigger title="Quick Actions" mode="actions">
  Actions
</FloatingActionPanelTrigger>

FloatingActionPanelContent

The content container for the floating panel.

<FloatingActionPanelContent>
  {/* Panel content */}
</FloatingActionPanelContent>

FloatingActionPanelButton

A styled button for use within the panel.

<FloatingActionPanelButton onClick={() => console.log("Clicked")}>
  <Icon className="h-4 w-4" />
  Button Text
</FloatingActionPanelButton>

FloatingActionPanelForm

A form component for note-taking mode.

<FloatingActionPanelForm onSubmit={handleSubmit}>
  {/* Form content */}
</FloatingActionPanelForm>

FloatingActionPanelTextarea

A textarea component for use within the form.

<FloatingActionPanelTextarea className="h-24" id="note" />

Props

FloatingActionPanelRoot

PropTypeDescription
children(context: PanelContext) => ReactNodeRender function with panel context
classNamestringAdditional CSS classes

FloatingActionPanelTrigger

PropTypeDescription
titlestringTitle displayed in the panel header
mode"actions" | "note"Panel mode to activate
childrenReactNodeTrigger button content
classNamestringAdditional CSS classes

FloatingActionPanelContent

PropTypeDescription
childrenReactNodePanel content
classNamestringAdditional CSS classes

FloatingActionPanelButton

PropTypeDescription
onClick() => voidClick handler
childrenReactNodeButton content
classNamestringAdditional CSS classes

FloatingActionPanelForm

PropTypeDescription
onSubmit(note: string) => voidForm submit handler
childrenReactNodeForm content
classNamestringAdditional CSS classes

Features

  • Multiple trigger buttons with different modes
  • Smooth animations with Framer Motion
  • Backdrop blur effect
  • Keyboard navigation and accessibility
  • Dark mode support
  • Responsive design
  • Form handling for note-taking
  • TypeScript support

Notes

  • Built with Framer Motion for smooth animations
  • Uses Lucide React for consistent iconography
  • Supports multiple panel modes (actions, notes)
  • Includes keyboard navigation (Escape to close)
  • Click outside to close functionality
  • Fully typed with TypeScript
  • Customizable styling with Tailwind CSS
  • Mobile-friendly design