Dropdown

The b.Dropdown constructor creates a dropdown menu.

ModifierAction
b.ActiveOpen the menu
b.ClickableMake the menu open when the button is clicked (javascript is automatically added)
b.HoverableMake the menu open when the cursor hovers the button
b.UpMake the dropdown open to the top
ChildAction
b.OnDropdown(...any)Apply children to the <div class="dropdown"> element
b.OnTrigger(...any)Apply children to the <div class="dropdown-trigger"> element
b.OnMenu(...any)Apply children to the <div class="dropdown-menu"> element
b.OnContent(...any)Apply children to the <div class="dropdown-content"> element
b.DropdownButton(...any)Make this button (part of) the trigger
b.DropdownDivider(...any)Apply divider to the <div class="dropdown-content"> element
b.DropdownItem(...any)Apply item to the <div class="dropdown-content"> element
b.DropdownAHref(...any)Apply link item to the <div class="dropdown-content"> element
b.IDSet the ID of the <div class="dropdown-menu"> element
e.ClassApply class to the <div class="dropdown"> element
stringCreate a dropdown button with this label
e.ElementWrap child with the b.DropdownItem constructor and add it to the <div class="dropdown-content"> element
gomponents.Nodeof type gomponents.AttributeTypeApply child to the <div class="dropdown"> element
gomponents.Nodeof type gomponents.ElementTypeWrap child with the b.DropdownItem constructor and add it to the <div class="dropdown-content"> element
Anything elseApply child to the <div class="dropdown"> element

The b.DropdownButton constructor creates a button to be used as a dropdown trigger. It automatically adds a Font Awesome icon to the right if no icon is provided.

The b.DropdownItem constructor creates a dropdown item.

The b.DropdownAHref constructor creates a dropdown link item.

The b.DropdownDivider constructor creates a dropdown divider.

Bulma examples

Example
Code
b.Dropdown(
	b.Clickable,
	b.OnTrigger(
		b.Button(
			e.AriaHasPopupTrue,
			e.AriaControlsID("dropdown-menu"),
			"Dropdown button",
			fa.Icon(fa.Solid, "angle-down", b.Small),
		),
	),
	b.ID("dropdown-menu"),
	b.DropdownAHref("#", "Dropdown item"),
	b.DropdownItem(html.A, "Other dropdown item"),
	b.DropdownAHref("#", b.Active, "Active dropdown item"),
	b.DropdownAHref("#", "Other dropdown item"),
	b.DropdownDivider(),
	b.DropdownAHref("#", "With a divider"),
	b.Active,
)
ResultHTML

Hoverable or Toggable

Bulma-Gomponents provides theeasy.ClickableDropdown and easy.HoverableDropdownvariants:

Example
Code
b.Dropdown(
	b.Clickable,
	"Click me",
	b.DropdownAHref("#", "Overview"),
	b.DropdownAHref("#", "Modifiers"),
	b.DropdownAHref("#", "Grid"),
	b.DropdownAHref("#", "Form"),
	b.DropdownAHref("#", "Elements"),
	b.DropdownAHref("#", "Components"),
	b.DropdownAHref("#", "Layout"),
	b.DropdownDivider(),
	b.DropdownAHref("#", "More"),
)
ResultHTML
Example
Code
b.Dropdown(
	b.Hoverable,
	"Hover me",
	e.P("You can insert ", e.Strong("any type of content"), " within the dropdown menu."),
)
ResultHTML

Right aligned

Example
Code
b.Dropdown(
	b.Clickable,
	b.DropdownButton("Left aligned"),
	e.P("The dropdown is ", e.Strong("left-aligned"), " by default."),
)
ResultHTML
Example
Code
b.Dropdown(
	b.Clickable,
	b.Right,
	b.DropdownButton("Right aligned"),
	e.P("Add the ", e.Code("b.Right"), " modifier for a ", e.Strong("right-aligned"), " dropdown."),
)
ResultHTML

Dropup

Example
Code
b.Dropdown(
	b.Clickable,
	b.Up,
	e.P("You can use the ", e.Code("b.Up"), " modifier to have a dropdown menu that appears above the dropdown button."),
)
ResultHTML