Reference
Family - Button
Unified reference for the Button widget family across module, constructor, and element APIs.
Version: latest | Last updated: 2026-02-19
Family - Button
This page unifies related iced::widget APIs for the Button family.
# API surfaces
- Module: iced::widget::button
- Constructor: iced::widget::button
- Element: iced::widget::Button
# Surface summaries
# Module
Buttons allow your users to perform actions by pressing them.
# Constructor
Creates a new Button with the provided content.
# Element
A generic widget that produces a message when pressed.
# Verified constructor signature
rust
pub fn button<'a, Message, Theme, Renderer>( content: impl Into<Element<'a, Message, Theme, Renderer>>, ) -> Button<'a, Message, Theme, Renderer> where Theme: Catalog + 'a, Renderer: Renderer,
# Verified element declaration
rust
pub struct Button<'a, Message, Theme = Theme, Renderer = Renderer<Renderer, Renderer>> where Renderer: Renderer, Theme: Catalog,{ /* private fields */ }
# Example References
- ref/examples/editor/src/main.rs
- ref/examples/loupe/src/main.rs
- ref/examples/modal/src/main.rs
- ref/examples/todos/src/main.rs
- ref/examples/pokedex/src/main.rs
- ref/examples/game_of_life/src/main.rs
# Inline Examples (from rustdoc)
# Constructor example
rust
use iced::widget::button; #[derive(Clone)] enum Message { ButtonPressed, } fn view(state: &State) -> Element<'_, Message> { button("Press me!").on_press(Message::ButtonPressed).into() }
# Element example
rust
use iced::widget::button; #[derive(Clone)] enum Message { ButtonPressed, } fn view(state: &State) -> Element<'_, Message> { button("Press me!").on_press(Message::ButtonPressed).into() }
# Related
# Use this when...
- You want one page that links module, constructor, and element surfaces.
- You are deciding which API surface to start from.
- You need a practical map for this widget domain.
# Minimal example
rust
// Typical flow: // 1) Start with constructor usage. // 2) Move to module docs for style/state details. // 3) Use element docs for type-level control.
# How it works
Family pages connect related docs so you do not miss capabilities that are split across constructor/module/element pages.
# Common patterns
rust
// Build with constructor APIs first, // then refine behavior/styles through related module and element docs.
# Gotchas / tips
- Family routes normalize naming; module/function/struct names may differ slightly.
- Prefer this page as your entrypoint when learning unfamiliar widgets.
- Follow example references here before inventing integration patterns.