iced

Iced Docs

Source-verified docs generated from /src/content.

Reference

Element - Radio

Struct reference for iced::widget::Radio.

Version: latest | Last updated: 2026-02-19

Element - Radio

Authoritative source: ref/doc/iced/widget/struct.Radio.html.

# Rustdoc summary

A circular button representing a choice.

# Verified type declaration

rust
pub struct Radio<'a, Message, Theme = Theme, Renderer = Renderer<Renderer, Renderer>>
where
    Theme: Catalog,
    Renderer: Renderer,{ /* private fields */ }

# When to use

Use this element struct when you need direct type-level control over a widget value.

# Why to use

It enables strongly typed composition and explicit builder method flows.

# Example References

  • ref/examples/tour/src/main.rs
  • ref/examples/scrollable/src/main.rs

# Inline Examples (from rustdoc)

rust
use iced::widget::{column, radio};

struct State {
   selection: Option<Choice>,
}

#[derive(Debug, Clone, Copy)]
enum Message {
    RadioSelected(Choice),
}

#[derive(Debug, Clone, Copy, PartialEq, Eq)]
enum Choice {
    A,
    B,
    C,
    All,
}

fn view(state: &State) -> Element<'_, Message> {
    let a = radio(
        "A",
        Choice::A,
        state.selection,
        Message::RadioSelected,
    );

    let b = radio(
        "B",
        Choice::B,
        state.selection,
        Message::RadioSelected,
    );

    let c = radio(
        "C",
        Choice::C,
        state.selection,
        Message::RadioSelected,
    );

    let all = radio(
        "All of the above",
        Choice::All,
        state.selection,
        Message::RadioSelected
    );

    column![a, b, c, all].into()
}

# Use this when...

  • You need the concrete widget struct type in signatures.
  • You are debugging type errors involving generic bounds.
  • You want lower-level control than constructor-only docs provide.

# Minimal example

rust
// Constructors usually produce this element type.
// Name the type explicitly only when type-level APIs need it.

# How it works

Element structs are the underlying widget types used by constructors. Most app code can stay constructor-first, then use element docs for advanced typing/customization.

# Common patterns

rust
// Use constructors in normal UI code,
// and reserve explicit element types for reusable abstractions.

# Gotchas / tips

  • You usually do not need to construct element structs directly.
  • Read trait bounds carefully when adding custom renderer/theme types.
  • If a method is missing, check the related module page.