跳到正文

Radio

单个可选项,通常在 RadioGroup 中声明。

正在加载交互演示…

#导入

从 quickgui 导入 Radio。

use quickgui::*;

#用法

let radio = Radio::new(selected);
radio
    .root().flex_row().gap(8.0).on_click(select)
    .child(radio.indicator_with(div().size(16.0, 16.0).rounded(8.0)))
    .child(text("Option A"))

#结构

  • Radio::root
  • Radio::indicator

#API 参考

展开条目查看说明和完整签名。短横线表示声明中未记录默认值。

pub const fn new(selected: 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`. A read-only radio stays focusable and keeps taking part in arrow navigation; only the selection it would make is refused.

pub const fn read_only(mut self, read_only: bool) -> Self
查看源码
is_selectedpub const fn is_selected(self) -> bool—

Configures is selected for this part.

pub const fn is_selected(self) -> bool
查看源码
is_read_onlypub const fn is_read_only(self) -> bool—

Configures is read only for this part.

pub const fn is_read_only(self) -> bool
查看源码
accepts_selectionpub const fn accepts_selection(self) -> bool—

Whether activating this radio may select it.

pub const fn accepts_selection(self) -> bool
查看源码

Radio::root_with

查看源码
pub fn root_with(self, root: Element) -> Element

Decorate an application-owned root without adding layout or appearance.

Radio::root

查看源码
pub fn root(self) -> Element

Create the unstyled root part. Use [`Self::root_with`] to supply an existing element.

Radio::indicator_with

查看源码
pub fn indicator_with(self, indicator: Element) -> Element

Hide an application-owned visual indicator from the accessible name.

Radio::indicator

查看源码
pub fn indicator(self) -> Element

Create the unstyled indicator part. Use [`Self::indicator_with`] to supply an existing element.

pub fn radio(selected: bool) -> Element

Create an unstyled controlled radio root. This shorthand is equivalent to `Radio::new(selected).root_with(div())`.