Reference
Constructor - Radio
Function reference for iced::widget::radio.
Constructor - Radio
Authoritative source: ref/doc/iced/widget/fn.radio.html.
# Rustdoc summary
Creates a new Radio .
# Verified signature
rust
pub fn radio<'a, Message, Theme, Renderer, V>( label: impl Into<String>, value: V, selected: Option<V>, on_click: impl FnOnce(V) -> Message, ) -> Radio<'a, Message, Theme, Renderer> where Message: Clone, Theme: Catalog + 'a, Renderer: Renderer, V: Copy + Eq,
# When to use
Use this constructor/helper as the typed entrypoint for the widget or layout helper it creates.
# Why to use
It gives explicit widget construction with compile-time type checking and builder chaining.
# Example References
- ref/examples/scrollable/src/main.rs
- ref/examples/tour/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() }
# Related
# Use this when...
- You want the canonical entrypoint for creating this widget/helper.
- You need concrete constructor arguments and builder chaining.
- You are wiring UI interactions into typed messages.
# Minimal example
rust
// Call this constructor in `view`, then map events to Message variants.
# How it works
Constructors return typed widget values. You configure behavior via builder methods and emit Message values for update to handle.
# Common patterns
rust
// Keep constructor calls close to their message mapping. // Prefer small helper functions for repeated widget setups.
# Gotchas / tips
- Re-check argument order in the verified signature on this page.
- Keep side effects out of
view; trigger them fromupdatewith Task. - Use the related family page when deciding between module/element APIs.