Checkbox
独立してスタイルできるインジケーターを持つ、二値または不定状態の選択コントロールです。
デモを読み込み中…
let checkbox = Checkbox::new(checked);
checkbox
.root().flex_row().items_center().gap(8.0).on_click(toggle)
.child(checkbox.indicator_with(div().size(16.0, 16.0).rounded(4.0)))
.child(text("Remember me"))#インポート
quickgui から Checkbox をインポートします。
use quickgui::*;#使い方
let checkbox = Checkbox::new(checked);
checkbox
.root().flex_row().items_center().gap(8.0).on_click(toggle)
.child(checkbox.indicator_with(div().size(16.0, 16.0).rounded(4.0)))
.child(text("Remember me"))#構成
Checkbox::rootCheckbox::indicator
#API リファレンス
項目を展開すると説明と完全なシグネチャが表示されます。ダッシュは宣言に既定値が記載されていないことを示します。
Checkbox
ソースを見るpub fn new(state: impl Into<ToggleState>) -> Selfparentpub fn parent(children: impl IntoIterator<Item = bool>) -> Self—
Derive a parent checkbox from the checked values of the boxes it governs. This is Base UI's `parent` checkbox: every child checked reports on, none reports off, and a mix reports mixed. QuickGUI keeps no child registry — the application passes the values it is already rendering — so the derivation stays a pure function of the caller's own data. ``` use quickgui::{Checkbox, ToggleState}; assert_eq!(Checkbox::parent([true, true]).state(), ToggleState::On); assert_eq!(Checkbox::parent([false, false]).state(), ToggleState::Off); assert_eq!(Checkbox::parent([true, false]).state(), ToggleState::Mixed); // An empty group is unchecked rather than mixed. assert_eq!(Checkbox::parent([]).state(), ToggleState::Off); ```
pub fn parent(children: impl IntoIterator<Item = bool>) -> Selfソースを見るread_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`. Unlike a disabled checkbox, a read-only one stays focusable and stays in the Tab sequence. QuickGUI projects the state and refuses the transition through [`Self::next_state`]; the application's own listener asks for that transition rather than toggling blindly.
pub const fn read_only(mut self, read_only: bool) -> Selfソースを見るstatepub const fn state(self) -> ToggleState—
is_read_onlypub const fn is_read_only(self) -> bool—
next_statepub const fn next_state(self) -> Option<ToggleState>—
The state an activation moves this checkbox to, or `None` when it refuses. Mixed and off both move to on, and on moves to off, which is the web's tri-state contract. A read-only checkbox returns `None`, so a click listener that asks before writing cannot change a value the control is refusing.
pub const fn next_state(self) -> Option<ToggleState>ソースを見るparent_next_checkedpub const fn parent_next_checked(self) -> Option<bool>—
The checked value activating a parent checkbox moves its whole group to. A partially or fully unchecked parent checks everything; a fully checked one clears it. Returns `None` when the parent is read-only.
pub const fn parent_next_checked(self) -> Option<bool>ソースを見るCheckbox::root_with
ソースを見るpub fn root_with(self, root: Element) -> ElementDecorate an application-owned root without adding layout or appearance.
Checkbox::root
ソースを見るpub fn root(self) -> ElementCreate the unstyled root part. Use [`Self::root_with`] to supply an existing element.
Checkbox::indicator_with
ソースを見るpub fn indicator_with(self, indicator: Element) -> ElementHide an application-owned visual indicator from the accessible name.
Checkbox::indicator
ソースを見るpub fn indicator(self) -> ElementCreate the unstyled indicator part. Use [`Self::indicator_with`] to supply an existing element.
checkbox
ソースを見るpub fn checkbox(state: impl Into<ToggleState>) -> ElementCreate an unstyled controlled checkbox root. This shorthand is equivalent to `Checkbox::new(state).root_with(div())`. Use [`Checkbox`] directly when composing a separate indicator part.
