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-grey-700">
      <a
        href="#"
        class="block px-4 py-2 hover:bg-grey-100"
      >Dashboard</a>
      <a
        href="#"
        class="block px-4 py-2 hover:bg-grey-100"
      >Settings</a>
      <a
        href="#"
        class="block px-4 py-2 hover:bg-grey-100"
      >Earnings</a>
      <a
        href="#"
        class="block px-4 py-2 hover:bg-grey-100"
      >Sign out</a>
    </nav>
  </pub-dropdown>
</template>

<script lang="ts" 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-grey-700">
            <a href="#" class="block px-4 py-2 hover:bg-grey-100"> Dashboard </a>
            <a href="#" class="block px-4 py-2 hover:bg-grey-100"> Settings </a>
            <a href="#" class="block px-4 py-2 hover:bg-grey-100"> Earnings </a>
            <a href="#" class="block px-4 py-2 hover:bg-grey-100"> Sign out </a>
        </nav>
    </pub-dropdown>

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

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

    <pub-dropdown placement="left" text="Left">
        <nav class="py-2 text-sm text-grey-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-grey-700">
            <a href="#" class="block px-4 py-2 hover:bg-grey-100"> Dashboard </a>
            <a href="#" class="block px-4 py-2 hover:bg-grey-100"> Settings </a>
            <a href="#" class="block px-4 py-2 hover:bg-grey-100"> Earnings </a>
            <a href="#" class="block px-4 py-2 hover:bg-grey-100"> Sign out </a>
        </nav>
    </pub-dropdown>

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

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

    <pub-dropdown align-to-end placement="left" text="Left">
        <nav class="py-2 text-sm text-grey-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-grey-700">
      <a
        href="#"
        class="block px-4 py-2 hover:bg-grey-100"
      > Dashboard </a>
      <a
        href="#"
        class="block px-4 py-2 hover:bg-grey-100"
      > Settings </a>
      <a
        href="#"
        class="block px-4 py-2 hover:bg-grey-100"
      > Earnings </a>
      <a
        href="#"
        class="block px-4 py-2 hover:bg-grey-100"
      > Sign out </a>
    </nav>
  </pub-dropdown>
</template>

<script lang="ts" 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-grey-700">
      <a
        href="#"
        class="block px-4 py-2 hover:bg-grey-100"
      > Dashboard </a>
      <a
        href="#"
        class="block px-4 py-2 hover:bg-grey-100"
      > Settings </a>
      <a
        href="#"
        class="block px-4 py-2 hover:bg-grey-100"
      > Earnings </a>
      <a
        href="#"
        class="block px-4 py-2 hover:bg-grey-100"
      > Sign out </a>
    </nav>
  </pub-dropdown>
  <pub-dropdown
    text="Right"
    placement="right"
    :offset-skidding="8"
  >
    <nav class="py-2 text-sm text-grey-700">
      <a
        href="#"
        class="block px-4 py-2 hover:bg-grey-100"
      > Dashboard </a>
      <a
        href="#"
        class="block px-4 py-2 hover:bg-grey-100"
      > Settings </a>
      <a
        href="#"
        class="block px-4 py-2 hover:bg-grey-100"
      > Earnings </a>
      <a
        href="#"
        class="block px-4 py-2 hover:bg-grey-100"
      > Sign out </a>
    </nav>
  </pub-dropdown>
  <pub-dropdown
    text="Bottom"
    :offset-skidding="8"
  >
    <nav class="py-2 text-sm text-grey-700">
      <a
        href="#"
        class="block px-4 py-2 hover:bg-grey-100"
      > Dashboard </a>
      <a
        href="#"
        class="block px-4 py-2 hover:bg-grey-100"
      > Settings </a>
      <a
        href="#"
        class="block px-4 py-2 hover:bg-grey-100"
      > Earnings </a>
      <a
        href="#"
        class="block px-4 py-2 hover:bg-grey-100"
      > Sign out </a>
    </nav>
  </pub-dropdown>
  <pub-dropdown
    text="Left"
    placement="left"
    :offset-skidding="8"
  >
    <nav class="py-2 text-sm text-grey-700">
      <a
        href="#"
        class="block px-4 py-2 hover:bg-grey-100"
      > Dashboard </a>
      <a
        href="#"
        class="block px-4 py-2 hover:bg-grey-100"
      > Settings </a>
      <a
        href="#"
        class="block px-4 py-2 hover:bg-grey-100"
      > Earnings </a>
      <a
        href="#"
        class="block px-4 py-2 hover:bg-grey-100"
      > Sign out </a>
    </nav>
  </pub-dropdown>
</template>

<script lang="ts" 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-grey-700">
      <a
        href="#"
        class="block px-4 py-2 hover:bg-grey-100"
      > Dashboard </a>
      <a
        href="#"
        class="block px-4 py-2 hover:bg-grey-100"
      > Settings </a>
      <a
        href="#"
        class="block px-4 py-2 hover:bg-grey-100"
      > Earnings </a>
      <a
        href="#"
        class="block px-4 py-2 hover:bg-grey-100"
      > Sign out </a>
    </nav>
  </pub-dropdown>
</template>

<script lang="ts" setup>
import { PubDropdown } from 'vuelicity'
</script>

Prop - color Usage

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

vue
<template>
    <pub-dropdown text="Red" color="red">
        <nav class="py-2 text-sm text-grey-700">...</nav>
    </pub-dropdown>
    <pub-dropdown text="Blue">
        <nav class="py-2 text-sm text-grey-700">...</nav>
    </pub-dropdown>
    <pub-dropdown text="Green" color="green">
        <nav class="py-2 text-sm text-grey-700">...</nav>
    </pub-dropdown>
    <pub-dropdown text="Yellow" color="yellow">
        <nav class="py-2 text-sm text-grey-700">...</nav>
    </pub-dropdown>
    <pub-dropdown text="Pink" color="pink">
        <nav class="py-2 text-sm text-grey-700">...</nav>
    </pub-dropdown>
    <pub-dropdown text="Cyan" color="cyan">
        <nav class="py-2 text-sm text-grey-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"
        color="pink"
      >
        Send
      </pub-button>
    </template>
    <nav class="py-2 text-sm text-grey-700">
      <a
        href="#"
        class="block px-4 py-2 hover:bg-grey-100"
      > Schedule </a>
      <a
        href="#"
        class="block px-4 py-2 hover:bg-grey-100"
      > Now </a>
    </nav>
  </pub-dropdown>
</template>

<script lang="ts" setup>
import { PubButton, PubDropdown } from 'vuelicity'
</script>

Reference

Properties

NameTypeDefaultDescriptionOptions
textString''The text to display on the dropdown button.
colorString'default'The color color of the dropdown trigger.'none', 'default', 'blue', 'red', 'green', 'yellow', 'pink', 'cyan', 'purple', 'grey'
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.
disabledBooleanfalseWhether the dropdown is disabled.
classString''Additional CSS classes to apply to the wrapper.
triggerClassString''Additional CSS classes to apply to the trigger button.
triggerWrapperClassString''Additional CSS classes to apply to the trigger wrapper.
dropdownClassString''Additional CSS classes to apply to the dropdown container.
contentWrapperClassString''Additional CSS classes to apply to the content wrapper.
durationNumber250The duration of the dropdown animation in milliseconds.
offsetDistanceNumber8The distance between the trigger and the dropdown.
offsetSkiddingNumber0The displacement along the trigger button.
isActiveBooleanfalseWhether the dropdown is currently active.
typeString'button'The type of the dropdown trigger.'button', 'navlink'
closeInsideBooleanfalseWhether to close the dropdown when clicking inside the content.

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.