Dropdown
Accessible dropdown menu with keyboard navigation, nested submenus, and menu items
Same BEM classes and behavior as Astro, Svelte, and React.
Add this component
The command below includes <strong>Dropdown</strong>—run it in your project directory to install this component (and the CSS if needed). No prompts.
Choose your package manager — click a tab to select, then copy the command.
npx rizzo-css add Dropdown
pnpm dlx rizzo-css add Dropdown
npx rizzo-css add Dropdown
bunx rizzo-css add Dropdown
Live examples
Usage
Usage
Full example for each framework (Astro, Vanilla, Svelte, Vue, React). Switch framework via View as or by clicking a Usage tab—both stay in sync.
Astro Vanilla Svelte Vue React ---
import Dropdown from '../components/astro/Dropdown.astro';
---
<Dropdown trigger="Actions" client:load>
<a href="#" class="dropdown__item">Edit</a>
<a href="#" class="dropdown__item">Duplicate</a>
<div class="dropdown__separator" role="separator" />
<a href="#" class="dropdown__item">More</a>
</Dropdown>
<!-- Rizzo CSS + dropdown script from package/vanilla docs. -->
<div class="dropdown">
<button class="dropdown__trigger" aria-haspopup="true">Menu</button>
<div class="dropdown__menu" role="menu">...</div>
</div>
<script>
import { Dropdown } from '$lib/rizzo';
</script>
<Dropdown trigger="Actions" items={[
{ label: 'Edit' },
{ label: 'Duplicate' },
{ separator: true },
{ label: 'More', submenu: [{ label: 'Option A' }, { label: 'Option B' }] },
]} />
<script setup>
import Dropdown from '@/components/rizzo/Dropdown.vue';
</script>
<template>
<Dropdown
trigger="Actions"
:items="[
{ label: 'Edit' },
{ label: 'Duplicate' },
{ separator: true },
{ label: 'More', submenu: [{ label: 'Option A' }, { label: 'Option B' }] },
]"
/>
</template>
import { Dropdown } from './components/react';
<Dropdown trigger="Actions" items={[
{ label: 'Edit', href: '#' },
{ label: 'Duplicate', href: '#' },
{ separator: true },
{ label: 'More', href: '#' },
]} />
Other frameworks: Astro · Vanilla · Svelte · React