mirror of
https://github.com/huntabyte/shadcn-svelte.git
synced 2026-09-14 19:33:46 +08:00
7ff65b4892
Co-authored-by: Crush <crush@charm.land> Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
2.9 KiB
2.9 KiB
title, description, component, links
| title | description | component | links |
|---|---|---|---|
| Dropdown Menu | Displays a menu to the user — such as a set of actions or functions — triggered by a button. | true |
Installation
{#snippet cli()} {/snippet} {#snippet manual()}Install bits-ui:
Copy and paste the following code into your project.
{#if viewerData} {/if} {/snippet}Usage
<script lang="ts">
import * as DropdownMenu from "$lib/components/ui/dropdown-menu/index.js";
</script>
<DropdownMenu.Root>
<DropdownMenu.Trigger>Open</DropdownMenu.Trigger>
<DropdownMenu.Content>
<DropdownMenu.Group>
<DropdownMenu.Label>My Account</DropdownMenu.Label>
<DropdownMenu.Separator />
<DropdownMenu.Item>Profile</DropdownMenu.Item>
<DropdownMenu.Item>Billing</DropdownMenu.Item>
<DropdownMenu.Item>Team</DropdownMenu.Item>
<DropdownMenu.Item>Subscription</DropdownMenu.Item>
</DropdownMenu.Group>
</DropdownMenu.Content>
</DropdownMenu.Root>
Examples
Checkboxes
Radio Group
Dialog
This example shows how to open a dialog from a dropdown menu.
<DropdownMenu.Root>
<DropdownMenu.Trigger class={buttonVariants({ variant: "outline" })}>
Actions
</DropdownMenu.Trigger>
</DropdownMenu.Root>
Changelog
2024-10-30 Classes for DropdownMenu.SubTrigger
- Added
gap-2 [&_svg]:pointer-events-none [&_svg]:size-4 [&_svg]:shrink-0to the<DropdownMenu.SubTrigger>to automatically style icon inside the dropdown menu sub trigger. - Removed
size-4from the icon inside the<DropdownMenu.SubTrigger>since it is now handled by the parent<DropdownMenu.SubTrigger>.