Skip to content
Back

Checkbox

A real checkbox with a label and second line, an indeterminate state for Select all, an error, a card row and a check that draws itself.

oxyn add checkbox
MCP
Dioxus
rsx! {
    Checkbox {
        label: "Run tests after every edit",
        description: "Slower, but catches breakage early",
        value: "checked",
        on_change: move |c: Check| run_tests.set(c),
    }
}

Rendered from Rust at build time · goes live when visible

When to use

  • A real checkbox with a label and second line, an indeterminate state for Select all, an error, a card row and a check that draws itself.

When not to use

Installation

Checkbox is free and MIT. The oxyn CLI copies its code, and the components it needs, into src/oxyn/ of your Dioxus or GPUI project, so it is yours to change.

Terminal
cargo install --git https://github.com/ismailqureshi72/Oxyn oxyn-cli
oxyn init
oxyn add checkbox
Rust
use crate::oxyn::{Checkbox, PRIMITIVES_CSS};

Rather depend on the crate? cargo add oxyn-dioxus oxyn-core --git https://github.com/ismailqureshi72/Oxyn, then use oxyn_dioxus::{Checkbox, PRIMITIVES_CSS};

Usage

Dioxus · rust
rsx! {
    Checkbox {
        label: "Run tests after every edit",
        description: "Slower, but catches breakage early",
        value: "checked",
        on_change: move |c: Check| run_tests.set(c),
    }
}

Examples

Plain

Label and second line.

Code
rsx! {
    Checkbox {
        label: "Run tests after every edit",
        description: "Slower, but catches breakage early",
        value: "checked",
        on_change: move |c: Check| run_tests.set(c),
    }
}

Card

A whole card row.

Code
rsx! {
    Checkbox {
        label: "Run tests after every edit",
        description: "Slower, but catches breakage early",
        value: "checked",
        variant: "card",
        on_change: move |c: Check| run_tests.set(c),
    }
}

Todo

Strikes the label through when done (Oxyn plus).

Code
rsx! {
    Checkbox {
        label: "Write the migration",
        value: "checked",
        variant: "todo",
        on_change: move |c: Check| run_tests.set(c),
    }
}

Bulk

An approve-all row over a list (Oxyn plus).

Code
rsx! {
    Checkbox {
        label: "Approve all 4 edits",
        value: "indeterminate",
        variant: "bulk",
        on_change: move |c: Check| run_tests.set(c),
    }
}

Indeterminate

Some of them: Select all.

Code
rsx! {
    Checkbox {
        label: "Select all files",
        value: "indeterminate",
        on_change: move |c: Check| run_tests.set(c),
    }
}

Error

Required, with its error in place.

Code
rsx! {
    Checkbox {
        label: "I understand this deletes the branch",
        error: "Tick this to continue",
        on_change: move |c: Check| run_tests.set(c),
    }
}

API reference

Checkbox

PropTypeDefaultDescription
labelrequiredString—Label.
descriptionOption<String>Default::default()Second line.
valueString"unchecked"`unchecked` · `checked` · `indeterminate`.
errorOption<String>Default::default()Error text (also marks it invalid).
variantString"plain"`plain` · `card` · `todo` (strike-through when checked) · `bulk` (approve-all row).
aria_labelOption<String>Default::default()Accessible name when there is no visible label (falls back to "Checkbox").
nameOption<String>Default::default()Form field name.
requiredboolDefault::default()Required.
sizeString"md"`sm` · `md` · `lg`.
speedf321.0Draw-time multiplier (1 = 240 ms).
tri_stateboolDefault::default()Cycle through indeterminate on click.
disabledboolDefault::default()Disabled.
on_changeEventHandler<Check>—Changed.

Read from the Rust signature and doc comments.

Keyboard interactions

KeyAction
SpaceToggle
TabNext control

Accessibility

  • role=checkbox with aria-checked (mixed when indeterminate).
  • The error is linked with aria-describedby and sets aria-invalid.

Responsive behaviour

  • The card variant fills its container.
  • The label is part of the hit area.

Notes for AI

  • Import Checkbox from oxyn_dioxus and include PRIMITIVES_CSS plus the token stylesheet once.
  • A GPUI version exists: CheckboxEl in oxyn_gpui.
  • Props to set first: label.
  • Keep its states and timings as they ship; restyle it through the CSS variables rather than by hand.

Guides

Oxyn · 74 free components · 264 Pro components · 96 screens · 20 blocks · Dioxus and GPUI