Floating Action Button
Modern floating action button with smooth animations, expandable menu options, and elegant hover effects. Perfect for mobile-first applications and quick actions.
Responsive Design
Yes
Dark Mode Support
Yes
lines
602
Browser Compatibility
No
Live Preview
Interact with the component without leaving the page.
Floating Action Button
A modern and accessible floating action button (FAB) component with expandable menu options, smooth animations, and comprehensive interaction support. Perfect for mobile-first applications and quick access to primary actions.
Features
- Expandable Menu: Smooth animation with staggered item appearance
- Multiple Actions: Support for message, call, email, and share functions
- Hover Tooltips: Contextual labels for better user experience
- Ripple Effects: Material Design-inspired touch feedback
- Keyboard Navigation: Full accessibility with arrow key support
- Screen Reader Support: ARIA labels and live announcements
- Mobile Optimized: Touch-friendly sizing and responsive design
- Dark Mode Support: Automatic adaptation to system preferences
Interaction States
- Idle State: Subtle pulse animation to draw attention
- Hover Effects: Scale and shadow transformations
- Active State: Rotation animation and menu expansion
- Focus States: Keyboard navigation indicators
- Loading States: Smooth transitions during actions
Accessibility Features
- WCAG 2.1 AA compliant
- Keyboard navigation with arrow keys
- Screen reader announcements
- Focus management
- High contrast support
- Touch target sizing (44px minimum)
Customization Options
.fab-main {
background: linear-gradient(135deg, #your-primary, #your-secondary);
}.fab-container {
bottom: 1rem;left: 2rem;.fab-menu {
bottom: auto;
top: 70px;
Action Handlers
The component includes built-in handlers for common actions:
- Message: Opens messaging interface
- Call: Initiates phone call
- Email: Opens email client
- Share: Uses Web Share API with clipboard fallback
Browser Support
- Chrome 60+ (full support)
- Firefox 55+ (full support)
- Safari 12+ (full support)
- Edge 79+ (full support)
- iOS Safari 12+ (full support)
- Android Chrome 60+ (full support)
Performance Features
- Hardware-accelerated animations
- Efficient event delegation
- Minimal DOM manipulation
- Optimized for 60fps animations
- Lazy-loaded notification system
Integration Examples
const fab = new FloatingActionButton();
fab.addCustomAction('download', () => {
console.log('Download initiated');
});
fab.open(); // Open menu
fab.close(); // Close menu
fab.toggle(); // Toggle state HTML
33
lines
CSS
280
lines
JavaScript
289
lines
<div class="fab-container">
<button class="fab-main" id="fabMain" aria-label="Main action menu">
<span class="fab-icon main-icon">+</span>
<span class="fab-icon close-icon">Γ</span>
</button>
<div class="fab-menu" id="fabMenu">
<button class="fab-item" data-action="message" aria-label="Send message">
<span class="fab-icon">π¬</span>
<span class="fab-tooltip">Message</span>
</button>
<button class="fab-item" data-action="call" aria-label="Make a call">
<span class="fab-icon">π</span>
<span class="fab-tooltip">Call</span>
</button>
<button class="fab-item" data-action="email" aria-label="Send email">
<span class="fab-icon">βοΈ</span>
<span class="fab-tooltip">Email</span>
</button>
<button class="fab-item" data-action="share" aria-label="Share content">
<span class="fab-icon">π</span>
<span class="fab-tooltip">Share</span>
</button>
</div>
<div class="fab-overlay" id="fabOverlay"></div>
</div>