pub struct Button {
pub id: Option<NodeId>,
pub child: Option<Box<Node>>,
pub on_press: Option<ActionEnvelope>,
pub semantics: Option<Semantics>,
pub width: Option<f32>,
pub height: Option<f32>,
pub padding: Option<[f32; 4]>,
pub style: Option<ButtonStyleOverride>,
pub variant: ButtonVariant,
pub content_align: ButtonContentAlign,
pub disabled: bool,
}Expand description
A pressable button widget with built-in theming, hover/press states, and focus ring.
Buttons come in three visual ButtonVariants (Filled, Outline, Ghost)
and support flexible content alignment via ButtonContentAlign.
§Example
let on_press = ctx.bind(Submit, handle_submit as fn(&mut S, Submit));
Button {
child: Some(Box::new(Text::new("Submit").into_node())),
on_press: Some(on_press),
variant: ButtonVariant::Filled,
content_align: ButtonContentAlign::Center,
..Default::default()
}Fields§
§id: Option<NodeId>Explicit node identity (auto-generated if None).
child: Option<Box<Node>>The button’s content widget (typically [Text] or [Icon]).
on_press: Option<ActionEnvelope>Action dispatched when the button is pressed.
semantics: Option<Semantics>Custom semantics (overrides the default button semantics).
width: Option<f32>Fixed width in layout points.
height: Option<f32>Fixed height in layout points.
padding: Option<[f32; 4]>Custom padding [left, right, top, bottom] (overrides theme defaults).
style: Option<ButtonStyleOverride>Style overrides (reserved for future use).
variant: ButtonVariantVisual variant (Filled, Outline, or Ghost).
content_align: ButtonContentAlignHorizontal alignment of the child content.
disabled: boolWhen true, the button is greyed out and its on_press action is not
attached.
Implementations§
Trait Implementations§
Source§impl<'de> Deserialize<'de> for Button
impl<'de> Deserialize<'de> for Button
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
Source§impl Lower for Button
impl Lower for Button
Source§fn lower(&self, cx: &mut LoweringContext<'_>) -> NodeId
fn lower(&self, cx: &mut LoweringContext<'_>) -> NodeId
Auto Trait Implementations§
impl Freeze for Button
impl !RefUnwindSafe for Button
impl Send for Button
impl Sync for Button
impl Unpin for Button
impl UnsafeUnpin for Button
impl !UnwindSafe for Button
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> Downcast for Twhere
T: Any,
impl<T> Downcast for Twhere
T: Any,
Source§fn into_any(self: Box<T>) -> Box<dyn Any>
fn into_any(self: Box<T>) -> Box<dyn Any>
Box<dyn Trait> (where Trait: Downcast) to Box<dyn Any>. Box<dyn Any> can
then be further downcast into Box<ConcreteType> where ConcreteType implements Trait.Source§fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
Rc<Trait> (where Trait: Downcast) to Rc<Any>. Rc<Any> can then be
further downcast into Rc<ConcreteType> where ConcreteType implements Trait.Source§fn as_any(&self) -> &(dyn Any + 'static)
fn as_any(&self) -> &(dyn Any + 'static)
&Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &Any’s vtable from &Trait’s.Source§fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
&mut Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &mut Any’s vtable from &mut Trait’s.