diff --git a/docs/components/content/examples/DropdownExample.vue b/docs/components/content/examples/DropdownExampleBasic.vue
similarity index 100%
rename from docs/components/content/examples/DropdownExample.vue
rename to docs/components/content/examples/DropdownExampleBasic.vue
diff --git a/docs/components/content/examples/DropdownExampleMode.vue b/docs/components/content/examples/DropdownExampleMode.vue
new file mode 100644
index 00000000..af40fa61
--- /dev/null
+++ b/docs/components/content/examples/DropdownExampleMode.vue
@@ -0,0 +1,16 @@
+
+
+
+
+
+
+
diff --git a/docs/content/2.elements/4.dropdown.md b/docs/content/2.elements/4.dropdown.md
index baa1e466..67b7e71b 100644
--- a/docs/content/2.elements/4.dropdown.md
+++ b/docs/content/2.elements/4.dropdown.md
@@ -8,9 +8,20 @@ headlessui:
## Usage
+Pass an array of arrays to the `items` prop of the Dropdown component. Each array represents a group of items. Each item can have the following properties:
+
+- `label` - The label of the item.
+- `icon` - The icon of the item.
+- `avatar` - The avatar of the item. You can pass all the props of the [Avatar](/elements/avatar) component.
+- `shortcuts` - The shortcuts of the item.
+- `disabled` - Whether the item is disabled.
+- `click` - The click handler of the item.
+
+You can also pass properties from the [NuxtLink](https://nuxt.com/docs/api/components/nuxt-link#props) component such as `to`, `exact`, etc.
+
::component-example
#default
-:dropdown-example
+:dropdown-example-basic
#code
```vue
@@ -55,6 +66,35 @@ const items = [
```
::
+### Mode
+
+Use the `mode` prop to switch between `click` and `hover` modes.
+
+::component-example
+#default
+:dropdown-example-mode
+
+#code
+```vue
+
+
+
+
+
+
+
+```
+::
+
## Props
:component-props
diff --git a/src/runtime/components/elements/Dropdown.vue b/src/runtime/components/elements/Dropdown.vue
index 3be3bfb9..c20c5b65 100644
--- a/src/runtime/components/elements/Dropdown.vue
+++ b/src/runtime/components/elements/Dropdown.vue
@@ -15,7 +15,7 @@
-
+
@@ -127,7 +127,7 @@ export default defineComponent({
const ui = computed
>(() => defu({}, props.ui, appConfig.ui.dropdown))
- const popper = computed(() => defu({}, props.popper, ui.value.popper as PopperOptions))
+ const popper = computed(() => defu(props.mode === 'hover' ? { offsetDistance: 0 } : {}, props.popper, ui.value.popper as PopperOptions))
const [trigger, container] = usePopper(popper.value)
@@ -149,6 +149,12 @@ export default defineComponent({
}, 200)
})
+ const containerStyle = computed(() => {
+ const offsetDistance = (props.popper as PopperOptions)?.offsetDistance || (ui.value.popper as PopperOptions)?.offsetDistance || 8
+
+ return props.mode === 'hover' ? { paddingTop: `${offsetDistance}px`, paddingBottom: `${offsetDistance}px` } : {}
+ })
+
function onMouseOver () {
if (props.mode !== 'hover' || !menuApi.value) {
return
@@ -194,6 +200,7 @@ export default defineComponent({
ui,
trigger,
container,
+ containerStyle,
onMouseOver,
onMouseLeave,
omit