Skip to content

Floating Action Button

Menus and commandsWeb + NativeMIT
View in Storybook

Anchored floating action button with optional expanding actions menu.

bun add @otfdashkit/ui

Preview

Floating Action Button

Code

import { Settings } from 'lucide-react'
import { FloatingActionButton, Switch } from '@otfdashkit/ui'

export function Example() {
  return (
    <div className="relative w-full h-[400px] bg-background flex items-center justify-center">
      <div className="text-center space-y-1">
        <p className="text-sm font-semibold text-foreground">FloatingActionButton</p>
        <p className="text-xs text-muted-foreground">Generic FAB — any icon, any sections</p>
      </div>
      <FloatingActionButton
        icon={<Settings className="h-[18px] w-[18px]" />}
        label="Open settings"
        title="Quick Settings"
        position="bottom-right"
        sections={[
          {
            label: 'Notifications',
            content: (
              <div className="space-y-2">
                {['Email alerts', 'Push', 'Digest'].map(item => (
                  <div key={item} className="flex items-center justify-between">
                    <span className="text-xs text-foreground">{item}</span>
                    <Switch />
                  </div>
                ))}
              </div>
            ),
          },
        ]}
      />
    </div>
  )
}

Free with the SDK. This block ships in @otfdashkit/ui under the MIT license.

Props

Props declared in the FloatingActionButton source. Inherited HTML attributes are not listed.

PropTypeDefaultDescription
classNamestringExtra className on the root wrapper.
descriptionstringPanel subtitle shown below the title.
iconReactNodeIcon rendered inside the FAB. Defaults to a palette icon.
labelstring'Open panel'Tooltip / aria-label for the FAB button.
position'bottom-right' | 'bottom-left' | 'top-right' | 'top-left''bottom-right'Which corner to anchor the FAB.
sectionsFabSection[][]Sections of content to render inside the popover panel.
titlestringPanel title shown at the top of the popover.