Collapsible
通过触发器显示或隐藏单个面板,同时保留无障碍状态。
正在加载交互演示…
let disclosure = Collapsible::new("notes", open);
disclosure.root().child(disclosure.trigger_with(text("Notes")))#导入
从 quickgui 导入 Collapsible。
use quickgui::*;#用法
let disclosure = Collapsible::new("notes", open);
disclosure.root().child(disclosure.trigger_with(text("Notes")))#结构
Collapsible::rootCollapsible::triggerCollapsible::panel
#API 参考
展开条目查看说明和完整签名。短横线表示声明中未记录默认值。
Collapsible
查看源码pub fn new(root_id: impl Into<ElementId>, open: bool) -> Selfdisabledpub fn disabled(mut self, disabled: bool) -> Self—
keep_mountedpub const fn keep_mounted(mut self, keep_mounted: bool) -> Self—
Retain the closed panel as `display: none` instead of omitting it from the mounted tree.
pub const fn keep_mounted(mut self, keep_mounted: bool) -> Self查看源码statepub const fn state(self) -> CollapsibleState—
root_idpub const fn root_id(self) -> ElementId—
trigger_idpub fn trigger_id(self) -> ElementId—
panel_idpub fn panel_id(self) -> ElementId—
is_openpub const fn is_open(self) -> bool—
is_disabledpub const fn is_disabled(self) -> bool—
keeps_panel_mountedpub const fn keeps_panel_mounted(self) -> bool—
panel_is_mountedpub const fn panel_is_mounted(self) -> bool—
Collapsible::root_with
查看源码pub fn root_with(self, root: Element) -> ElementDecorate an application-owned structural root without adding role or appearance.
Collapsible::root
查看源码pub fn root(self) -> ElementCreate the unstyled root part. Use [`Self::root_with`] to supply an existing element.
Collapsible::trigger_with
查看源码pub fn trigger_with(self, trigger: Element) -> ElementDecorate an application-owned trigger with disclosure-button behavior.
Collapsible::trigger
查看源码pub fn trigger(self) -> ElementCreate the unstyled trigger part. Use [`Self::trigger_with`] to supply an existing element.
Collapsible::panel_with
查看源码pub fn panel_with(self, panel: Element) -> Option<Element>Decorate the panel when it should be mounted. The default closed state returns `None`. Pass the result to [`Element::children`] so the `Option<Element>` composes directly. With [`Self::keep_mounted`], a closed panel remains in the retained tree as `display: none` and therefore contributes no layout, paint, input, or accessibility node.
Collapsible::panel
查看源码pub fn panel(self) -> Option<Element>Create the unstyled panel part. Use [`Self::panel_with`] to supply an existing element.
