Search

Simple Flyouts

Simple Flyout Menu

A basic flyout menu with icon and text items. Perfect for navigation menus and simple dropdowns.

Features

  • Icon + text layout - Clean visual hierarchy with icons
  • Smooth transitions - Professional animations
  • Click-outside-to-close - Intuitive user experience
  • Keyboard navigation - ESC to close, proper focus management
  • Smart positioning - Automatically positions below trigger
  • Teleport rendering - Prevents clipping in overflow containers
  • Dark mode support - Built-in theme compatibility
  • Responsive design - Works on all screen sizes

Usage

---
import SimpleFlyout from '/src/components/flyouts/SimpleFlyout.astro'
---

<!-- Basic usage -->
<SimpleFlyout />

<!-- With initial state -->
<SimpleFlyout open={true} />

Customization

Changing Menu Items

Update the <a> elements inside the flyout to match your content:

<a class="text-sm relative flex items-center w-full p-4 rounded-lg gap-2 group hover:bg-zinc-50 dark:hover:bg-white/5" href="#_">
  <svg class="icon icon-tabler-your-icon size-5 text-zinc-500 dark:text-zinc-400">
    <!-- Your icon SVG -->
  </svg>
  <h3 class="text-base font-medium text-zinc-900 dark:text-white">
    Your menu item
  </h3>
</a>

Styling the Button

Modify the button classes to change appearance:

<button class="your-custom-button-classes">
  <span>Your button text</span>
  <!-- Chevron icon -->
</button>

Adjusting Positioning

The gap variable controls spacing between button and flyout:

gap: 12, // Increase for more spacing

Accessibility

  • ARIA attributes - Proper aria-expanded and role attributes
  • Keyboard navigation - ESC to close, Tab to navigate items
  • Focus management - Proper focus handling for screen readers
  • Semantic HTML - Uses appropriate HTML elements for structure

Best Practices

  • Use descriptive icons that complement the text
  • Ensure sufficient color contrast for accessibility
  • Test keyboard navigation thoroughly
  • Consider mobile touch interactions
  • Keep menu items concise and actionable

Back to Flyout Menus