From 1f73c99cd63da09044bcfc77bb4b8f0f0b319d67 Mon Sep 17 00:00:00 2001 From: Davis SHYAKA <87414827+davis-shyaka@users.noreply.github.com> Date: Fri, 2 Aug 2024 10:11:39 +0200 Subject: [PATCH] next: Dropdown-Menu --- .../docs/content/components/dropdown-menu.md | 99 +++++++++++++++++++ 1 file changed, 99 insertions(+) diff --git a/sites/docs/content/components/dropdown-menu.md b/sites/docs/content/components/dropdown-menu.md index 9e6038db5..5bf38c6e4 100644 --- a/sites/docs/content/components/dropdown-menu.md +++ b/sites/docs/content/components/dropdown-menu.md @@ -16,4 +16,103 @@ description: Displays a menu of items that users can select from when triggered. +## Structure + +```svelte + + + + + + + + + + + + +``` + +## Reusable Components + +If you're planning to use Dropdown Menu in multiple places, you can create a reusable component that wraps the Dropdown Menu component. + +This example shows you how to create a Dropdown Menu component that accepts a few custom props that make it more capable. + +```svelte title="CustomDropdownMenu.svelte" + + + + + {buttonText} + + + {#each items as item} + + {item.label} + + {/each} + + +``` + +You can then use the `CustomDropdownMenu` component like this: + +```svelte + + + +``` + +## Managing Open State + +Bits UI provides flexible options for controlling and synchronizing the menu's open state. + +### Two-Way Binding + +Use the `bind:open` directive for effortless two-way synchronization between your local state and the menu's internal state. + +```svelte {3,6,8} + + + + + + + +``` +