Skip to content

PubDropdown

Default Dropdown

vue
<template>
    <pub-dropdown align-to-end placement="top" text="Dropdown button">
        <nav class="py-2 text-sm text-gray-700">
            <a href="#" class="block px-4 py-2 hover:bg-gray-100">Dashboard</a>
            <a href="#" class="block px-4 py-2 hover:bg-gray-100">Settings</a>
            <a href="#" class="block px-4 py-2 hover:bg-gray-100">Earnings</a>
            <a href="#" class="block px-4 py-2 hover:bg-gray-100">Sign out</a>
        </nav>
    </pub-dropdown>
</template>

<script setup>
import { PubDropdown } from "vuelicity";
</script>

Prop - placement Usage

The placement prop is used to specify the placement of the dropdown relative to the button.

vue
<template>
    <pub-dropdown placement="top" text="Top">
        <nav class="py-2 text-sm text-gray-700">
            <a href="#" class="block px-4 py-2 hover:bg-gray-100"> Dashboard </a>
            <a href="#" class="block px-4 py-2 hover:bg-gray-100"> Settings </a>
            <a href="#" class="block px-4 py-2 hover:bg-gray-100"> Earnings </a>
            <a href="#" class="block px-4 py-2 hover:bg-gray-100"> Sign out </a>
        </nav>
    </pub-dropdown>

    <pub-dropdown placement="right" text="Right">
        <nav class="py-2 text-sm text-gray-700">...</nav>
    </pub-dropdown>

    <pub-dropdown text="Bottom">
        <nav class="py-2 text-sm text-gray-700">...</nav>
    </pub-dropdown>

    <pub-dropdown placement="left" text="Left">
        <nav class="py-2 text-sm text-gray-700">...</nav>
    </pub-dropdown>
</template>

<script setup>
    import { PubDropdown } from "vuelicity";
</script>

Prop - alignToEnd Usage

The alignToEnd prop is used to align the dropdown to the end of the button.

vue
<template>
    <pub-dropdown align-to-end placement="top" text="Top">
        <nav class="py-2 text-sm text-gray-700">
            <a href="#" class="block px-4 py-2 hover:bg-gray-100"> Dashboard </a>
            <a href="#" class="block px-4 py-2 hover:bg-gray-100"> Settings </a>
            <a href="#" class="block px-4 py-2 hover:bg-gray-100"> Earnings </a>
            <a href="#" class="block px-4 py-2 hover:bg-gray-100"> Sign out </a>
        </nav>
    </pub-dropdown>

    <pub-dropdown align-to-end placement="right" text="Right">
        <nav class="py-2 text-sm text-gray-700">...</nav>
    </pub-dropdown>

    <pub-dropdown align-to-end text="Bottom">
        <nav class="py-2 text-sm text-gray-700">...</nav>
    </pub-dropdown>

    <pub-dropdown align-to-end placement="left" text="Left">
        <nav class="py-2 text-sm text-gray-700">...</nav>
    </pub-dropdown>
</template>

<script setup>
    import { PubDropdown } from "vuelicity";
</script>

Prop - offset-distance Usage

The offset-distance prop is used to specify the distance between the button and the dropdown.

vue
<template>
    <pub-dropdown text="Profile" :offset-distance="16">
        <nav class="py-2 text-sm text-gray-700">
            <a href="#" class="block px-4 py-2 hover:bg-gray-100"> Dashboard </a>
            <a href="#" class="block px-4 py-2 hover:bg-gray-100"> Settings </a>
            <a href="#" class="block px-4 py-2 hover:bg-gray-100"> Earnings </a>
            <a href="#" class="block px-4 py-2 hover:bg-gray-100"> Sign out </a>
        </nav>
    </pub-dropdown>
</template>

<script setup>
import { PubDropdown } from "vuelicity";
</script>

Prop - offset-skidding Usage

The offset-skidding prop is used to specify the skidding between the button and the dropdown.

vue
<template>
    <pub-dropdown text="Top" placement="top" :offset-skidding="8">
        <nav class="py-2 text-sm text-gray-700">
            <a href="#" class="block px-4 py-2 hover:bg-gray-100"> Dashboard </a>
            <a href="#" class="block px-4 py-2 hover:bg-gray-100"> Settings </a>
            <a href="#" class="block px-4 py-2 hover:bg-gray-100"> Earnings </a>
            <a href="#" class="block px-4 py-2 hover:bg-gray-100"> Sign out </a>
        </nav>
    </pub-dropdown>
    <pub-dropdown text="Right" placement="right" :offset-skidding="8">
        <nav class="py-2 text-sm text-gray-700">
            <a href="#" class="block px-4 py-2 hover:bg-gray-100"> Dashboard </a>
            <a href="#" class="block px-4 py-2 hover:bg-gray-100"> Settings </a>
            <a href="#" class="block px-4 py-2 hover:bg-gray-100"> Earnings </a>
            <a href="#" class="block px-4 py-2 hover:bg-gray-100"> Sign out </a>
        </nav>
    </pub-dropdown>
    <pub-dropdown text="Bottom" :offset-skidding="8">
        <nav class="py-2 text-sm text-gray-700">
            <a href="#" class="block px-4 py-2 hover:bg-gray-100"> Dashboard </a>
            <a href="#" class="block px-4 py-2 hover:bg-gray-100"> Settings </a>
            <a href="#" class="block px-4 py-2 hover:bg-gray-100"> Earnings </a>
            <a href="#" class="block px-4 py-2 hover:bg-gray-100"> Sign out </a>
        </nav>
    </pub-dropdown>
    <pub-dropdown text="Left" placement="left" :offset-skidding="8">
        <nav class="py-2 text-sm text-gray-700">
            <a href="#" class="block px-4 py-2 hover:bg-gray-100"> Dashboard </a>
            <a href="#" class="block px-4 py-2 hover:bg-gray-100"> Settings </a>
            <a href="#" class="block px-4 py-2 hover:bg-gray-100"> Earnings </a>
            <a href="#" class="block px-4 py-2 hover:bg-gray-100"> Sign out </a>
        </nav>
    </pub-dropdown>
</template>

<script setup>
import { PubDropdown } from "vuelicity";
</script>

Disabled Dropdown

Prop - disabled Usage

The disabled prop can be used to disable the dropdown.

vue
<template>
    <pub-dropdown text="Profile" disabled>
        <nav class="py-2 text-sm text-gray-700">
            <a href="#" class="block px-4 py-2 hover:bg-gray-100"> Dashboard </a>
            <a href="#" class="block px-4 py-2 hover:bg-gray-100"> Settings </a>
            <a href="#" class="block px-4 py-2 hover:bg-gray-100"> Earnings </a>
            <a href="#" class="block px-4 py-2 hover:bg-gray-100"> Sign out </a>
        </nav>
    </pub-dropdown>
</template>

<script setup>
import { PubDropdown } from "vuelicity";
</script>

Prop - theme Usage

The theme prop can be used to change the color of the dropdown trigger.

vue
<template>
    <pub-dropdown text="Red" theme="red">
        <nav class="py-2 text-sm text-gray-700">...</nav>
    </pub-dropdown>
    <pub-dropdown text="Blue">
        <nav class="py-2 text-sm text-gray-700">...</nav>
    </pub-dropdown>
    <pub-dropdown text="Green" theme="green">
        <nav class="py-2 text-sm text-gray-700">...</nav>
    </pub-dropdown>
    <pub-dropdown text="Yellow" theme="yellow">
        <nav class="py-2 text-sm text-gray-700">...</nav>
    </pub-dropdown>
    <pub-dropdown text="Magenta" theme="magenta">
        <nav class="py-2 text-sm text-gray-700">...</nav>
    </pub-dropdown>
    <pub-dropdown text="Cyan" theme="cyan">
        <nav class="py-2 text-sm text-gray-700">...</nav>
    </pub-dropdown>
    <pub-dropdown text="Light" theme="light">
        <nav class="py-2 text-sm text-gray-700">...</nav>
    </pub-dropdown>
    <pub-dropdown text="Dark" theme="dark">
        <nav class="py-2 text-sm text-gray-700">...</nav>
    </pub-dropdown>
</template>

<script setup>
    import { PubDropdown } from "vuelicity";
</script>

Slot - trigger Usage

The trigger slot can be used to customize the dropdown trigger.

vue
<template>
    <pub-dropdown>
        <template #trigger>
            <pub-button rounded="full" theme="magenta">Send</pub-button>
        </template>
        <nav class="py-2 text-sm text-gray-700">
            <a href="#" class="block px-4 py-2 hover:bg-gray-100"> Schedule </a>
            <a href="#" class="block px-4 py-2 hover:bg-gray-100"> Now </a>
        </nav>
    </pub-dropdown>
</template>

<script setup>
import { PubDropdown, PubButton } from "vuelicity";
</script>

Reference

Properties

NameTypeDefaultDescriptionOptions
textString''The text to display on the dropdown button.
themeString'default'The color theme of the dropdown trigger.'none', 'default', 'blue', 'red', 'yellow', 'green', 'magenta', 'cyan', 'light', 'dark'
placementString'bottom'The placement of the dropdown relative to the trigger.'top', 'right', 'bottom', 'left'
alignToEndBooleanfalseWhether to align the dropdown to the end of the trigger.
offsetDistanceNumber0The distance between the trigger and the dropdown.
offsetSkiddingNumber0The displacement along the trigger button.
disabledBooleanfalseWhether the dropdown is disabled.
classString''Additional CSS classes to apply to the wrapper.
triggerClassString''Additional CSS classes to apply to the trigger button.
dropdownClassString''Additional CSS classes to apply to the dropdown container.

Slots

NameDescription
defaultThe content of the dropdown menu.
triggerSlot to customize the dropdown trigger element.

Events

NameDescription
toggleEmitted when the dropdown is toggled.

Released under the MIT License.