pub struct DropdownProps {
pub open: Signal<bool>,
pub toggle: Element,
pub menu: Element,
pub class: String,
pub toggle_class: String,
pub direction: DropDirection,
pub align_end: bool,
pub split: bool,
pub color: Option<Color>,
/* private fields */
}Expand description
Bootstrap Dropdown component — signal-driven, no JavaScript.
Replaces Bootstrap’s dropdown JavaScript plugin with signal-controlled open/close. Supports split buttons, drop directions, and auto-closes on outside click.
§Bootstrap HTML → Dioxus
<!-- Bootstrap HTML (requires JavaScript) -->
<div class="dropdown">
<button class="btn btn-secondary dropdown-toggle" data-bs-toggle="dropdown">Menu</button>
<ul class="dropdown-menu">
<li><button class="dropdown-item">Action</button></li>
<li><hr class="dropdown-divider"></li>
<li><button class="dropdown-item">Other</button></li>
</ul>
</div>// Dioxus equivalent
let open = use_signal(|| false);
rsx! {
Dropdown { open: open,
toggle: rsx! { "Menu" },
menu: rsx! {
DropdownItem { "Action" }
DropdownDivider {}
DropdownItem { "Other" }
},
}
// Split button variant
Dropdown { open: open, split: true, color: Color::Danger,
toggle: rsx! { "Delete" },
menu: rsx! { DropdownItem { "Confirm Delete" } },
}
}§Props
open—Signal<bool>controlling open statetoggle— toggle button content (Element)menu— dropdown menu content (Element)split— split button mode (separate action button + caret toggle)color— button color in split modedirection—DropDirection::Down,Up,Start,Endalign_end— align menu to the right
Fields§
§open: Signal<bool>Signal controlling dropdown open state.
toggle: ElementToggle button content.
Dropdown menu content (DropdownItem components).
class: StringAdditional CSS classes for the dropdown container.
toggle_class: StringAdditional CSS classes for the toggle button.
direction: DropDirectionDrop direction.
align_end: boolAlign menu to the end (right).
split: boolSplit button mode — toggle is a separate caret-only button.
color: Option<Color>Color for split button mode (used for the main button).
Implementations§
Source§impl DropdownProps
impl DropdownProps
Sourcepub fn builder() -> DropdownPropsBuilder<((), (), (), (), (), (), (), (), (), ())>
pub fn builder() -> DropdownPropsBuilder<((), (), (), (), (), (), (), (), (), ())>
Create a builder for building DropdownProps.
On the builder, call .open(...), .toggle(...), .menu(...), .class(...)(optional), .toggle_class(...)(optional), .direction(...)(optional), .align_end(...)(optional), .split(...)(optional), .color(...)(optional), .attributes(...)(optional) to set the values of the fields.
Finally, call .build() to create the instance of DropdownProps.
Trait Implementations§
Source§impl Clone for DropdownProps
impl Clone for DropdownProps
Source§fn clone(&self) -> DropdownProps
fn clone(&self) -> DropdownProps
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more