Overview
AButton is a generic widget that produces a message when pressed. Buttons can contain any content (text, icons, or other widgets) and support various styling options.
Constructor
button::Button::new
Button with the given content.
Parameters:
content- The content to display inside the button (text, icon, or any widget)
Builder Methods
Event Handlers
on_press
on_press_with
on_press_maybe
None, the button will be disabled.
Layout
width
height
padding
Padding { top: 5.0, bottom: 5.0, right: 10.0, left: 10.0 }.
Appearance
clip
style
Status
TheStatus enum represents the possible states of a button:
Style
TheStyle struct defines the visual appearance:
Built-in Styles
The default theme provides several pre-defined button styles:primary- A primary button with strong colorsecondary- A secondary button with muted colorsuccess- A success button (green)warning- A warning button (yellow/orange)danger- A danger button (red)text- A text-only button without backgroundbackground- A button using background shadessubtle- A subtle button with weak colors
Examples
Basic Button
Disabled Button
Conditionally Enabled
Styled Button
Button with Custom Content
Custom Style Function
Related
Checkbox
For binary toggle inputs
Text Input
For text entry
