Skip to content

Component Checkbox

MeowLynxSea edited this page Jun 13, 2026 · 6 revisions

Checkbox

A boolean toggle. Headless — visuals come from the registered CheckboxRenderer.

Import

use yororen_ui::headless::checkbox::checkbox;

Minimal example

use yororen_ui::headless::checkbox::checkbox;

let checked = self.agreed;
checkbox("tos", cx)
    .checked(checked)
    .on_toggle({
        let entity = cx.entity();
        move |new: bool, _window, cx| {
            entity.update(cx, |s, _cx| s.agreed = new);
        }
    })
    .render(cx)

Props

Method Purpose
checked(v) Current checked state.
disabled(v) Disable interaction.
on_toggle(closure) Fn(bool, &mut Window, &mut App) + 'static + Send + Sync. Fired with the new value.
has_custom_tone(v) Tell the renderer the caller overrode the accent color.
custom_tone(hsla) Override the rendered accent color.

Notes

  • Factory takes (id, cx). The cx is needed so the renderer can mint the focus handle.
  • No Entity<CheckboxState> — toggle handling is wired inline.
  • Capture self in the callback with cx.entity().clone() and update the view through entity.update(cx, |s, _cx| { ... }).
  • .render(cx) returns Stateful<Div>.

See also

Switch, Radio, RadioGroup, ToggleButton

Clone this wiki locally