Switch
ルートのトラックと個別にスタイルできるつまみを持つ、オン/オフコントロールです。
デモを読み込み中…
let control = Switch::new(enabled);
control
.root().w(40.0).h(24.0).rounded(12.0).on_click(toggle)
.child(control.thumb_with(div().size(18.0, 18.0).rounded(9.0)))#インポート
quickgui から Switch をインポートします。
use quickgui::*;#使い方
let control = Switch::new(enabled);
control
.root().w(40.0).h(24.0).rounded(12.0).on_click(toggle)
.child(control.thumb_with(div().size(18.0, 18.0).rounded(9.0)))#構成
Switch::rootSwitch::thumb
#API リファレンス
項目を展開すると説明と完全なシグネチャが表示されます。ダッシュは宣言に既定値が記載されていないことを示します。
Switch
ソースを見るpub const fn new(checked: bool) -> Selfread_onlypub const fn read_only(mut self, read_only: bool) -> Self—
Show a value the user may read but not change, Base UI's `readOnly`. A read-only switch stays focusable and stays in the Tab sequence; only the toggle it would perform is refused, through [`Self::next_checked`].
pub const fn read_only(mut self, read_only: bool) -> Selfソースを見るis_checkedpub const fn is_checked(self) -> bool—
is_read_onlypub const fn is_read_only(self) -> bool—
next_checkedpub const fn next_checked(self) -> Option<bool>—
The value an activation moves this switch to, or `None` when it refuses.
pub const fn next_checked(self) -> Option<bool>ソースを見るSwitch::root_with
ソースを見るpub fn root_with(self, root: Element) -> ElementDecorate an application-owned root/track without adding layout or appearance.
Switch::root
ソースを見るpub fn root(self) -> ElementCreate the unstyled root part. Use [`Self::root_with`] to supply an existing element.
Switch::thumb_with
ソースを見るpub fn thumb_with(self, thumb: Element) -> ElementHide an application-owned visual thumb from the accessible name.
Switch::thumb
ソースを見るpub fn thumb(self) -> ElementCreate the unstyled thumb part. Use [`Self::thumb_with`] to supply an existing element.
switch
ソースを見るpub fn switch(checked: bool) -> ElementCreate an unstyled controlled switch root. This shorthand is equivalent to `Switch::new(checked).root_with(div())`. Use [`Switch`] directly when composing a separate thumb part.
