Ship faster with goilerplate templUI Pro

Dropdown

Floating menu for displaying a list of actions or options. Uses Popover for the popup.

Source Tailwind CSS JavaScript

My Account
GitHub

Installation

templui add dropdown

Load the script once in your layout:

<head>
  @dropdown.Script()
</head>

API Reference

Required parameter
Hover for description

Trigger

Name Type Default
ID

Unique identifier for the trigger element

string
""
Class

Additional CSS classes to apply to the trigger

string
""
Attributes

Additional HTML attributes to apply to the trigger

templ.Attributes
nil

Content

Name Type Default
ID

Unique identifier for the content element

string
""
Class

Additional CSS classes to apply to the content

string
""
Attributes

Additional HTML attributes to apply to the content

templ.Attributes
nil
Placement

Position of the dropdown relative to trigger (e.g., PlacementBottomEnd, PlacementTopStart)

dropdown.Placement
PlacementBottomStart

Group

Name Type Default
ID

Unique identifier for the group element

string
""
Class

Additional CSS classes to apply to the group

string
""
Attributes

Additional HTML attributes to apply to the group

templ.Attributes
nil

Label

Name Type Default
ID

Unique identifier for the label element

string
""
Class

Additional CSS classes to apply to the label

string
""
Attributes

Additional HTML attributes to apply to the label

templ.Attributes
nil

Item

Name Type Default
ID

Unique identifier for the item element

string
randomID
Class

Additional CSS classes to apply to the item

string
""
Attributes

Additional HTML attributes to apply to the item

templ.Attributes
nil
Disabled

Whether the item is disabled

bool
false
Href

URL to navigate to when item is clicked (renders as anchor)

string
""
Target

Target attribute for anchor items

string
""
PreventClose

Whether to prevent dropdown from closing when item is clicked

bool
false

Separator

Name Type Default
ID

Unique identifier for the separator element

string
""
Class

Additional CSS classes to apply to the separator

string
""
Attributes

Additional HTML attributes to apply to the separator

templ.Attributes
nil

Shortcut

Name Type Default
ID

Unique identifier for the shortcut element

string
""
Class

Additional CSS classes to apply to the shortcut

string
""
Attributes

Additional HTML attributes to apply to the shortcut

templ.Attributes
nil

Sub

Name Type Default
ID

Unique identifier for the submenu container

string
randomID
Class

Additional CSS classes to apply to the submenu container

string
""
Attributes

Additional HTML attributes to apply to the submenu container

templ.Attributes
nil

SubTrigger

Name Type Default
ID

Unique identifier for the submenu trigger

string
""
Class

Additional CSS classes to apply to the submenu trigger

string
""
Attributes

Additional HTML attributes to apply to the submenu trigger

templ.Attributes
nil

SubContent

Name Type Default
ID

Unique identifier for the submenu content

string
""
Class

Additional CSS classes to apply to the submenu content

string
""
Attributes

Additional HTML attributes to apply to the submenu content

templ.Attributes
nil