Dropdown

Display a dropdown.

Usage

Use a Dropdown that wraps Reka UI's dropdown components. It's composed compositionally with CDropdown with CDropdownItems wrapped inside the #items slot. The default slot is the trigger.

You can customise the placement of the dropdown using the placement prop.

The CDropdownItem can be customised in a variety of ways as seen below, featuring a prepended and appended icon using the #icon and #appendIcon slots, a destructive prop, as well a disabled prop.

You can also utilise the as prop to choose what the parent element is rendered as. This is useful for rendering links and anchor tags. It'll render an anchor tag by default.

      <template>
  <CDropdown>
    <template #items>
      <CDropdownItem
        as="RouterLink"
        to="/"
      >
        First item
      </CDropdownItem>
      <CDropdownItem
        as="a"
        href="/"
      >
        <template #icon>
          <CIcon
            name="i-heroicons-solid-trash"
            size="sm"
          />
        </template>
        Icon slot
      </CDropdownItem>
      <CDropdownItem
        as="a"
        href="/"
      >
        Append icon slot
        <template #appendIcon>
          <CIcon
            name="i-heroicons-solid-trash"
            size="sm"
          />
        </template>
      </CDropdownItem>
      <CDropdownItem
        disabled
        as="button"
        type="button"
      >
        Disabled item
      </CDropdownItem>
      <CTooltip content="Example tooltip">
        <CDropdownItem disabled>
          Tooltip example item
        </CDropdownItem>
      </CTooltip>
      <CDropdownItem
        destructive
        icon="i-heroicons-solid-trash"
      >
        Destructive item
      </CDropdownItem>
    </template>
  </CDropdown>
</template>

    

Float

The CDropdown float prop accepts the props for the DropdownMenuContent component from reka-ui. This allows you to control the positioning of the dropdown menu.

Props

Prop Default Type
defaultOpenboolean
modalfalseboolean
float DropdownMenuContentProps
portaltrue string | false | true | HTMLElement
openboolean
Prop Default Type
as"div" "input" | ComponentOptions<any, any, any, ComputedOptions, MethodOptions, any, any, any, string, {}, {}, string, {}, {}, {}, string, ComponentProvideOptions> | (props: any, ctx: Omit<{ attrs: Data; slots: Readonly<InternalSlots>; emit: (event: string, ...args: any[]) => void; expose: <Exposed extends Record<string, any> = Record<string, any>>(exposed?: Exposed | undefined) => void; }, "expose">): any | ComponentPublicInstanceConstructor<any, any, any, any, ComputedOptions, MethodOptions> | "button" | "label" | "a" | "div" | "form" | "h2" | "h3" | "img" | "li" | "nav" | "ol" | "p" | "span" | "svg" | "ul" | "template" | {} & string
The element or component this component should render as. Can be overwritten by asChild.
destructiveboolean
icon string
appendIcon string
disabledboolean
When true, prevents the user from interacting with the item.
textValue string
Optional text used for typeahead purposes. By default the typeahead behavior will use the .textContent of the item.
Use this when the content is complex, or you have non-textual content inside.
asChildboolean
Change the default rendered element for the one passed as a child, merging their props and behavior.Read our Composition guide for more details.