pub struct Button { /* private fields */ }Expand description
Button component styled like shadcn/ui
§Example
use armas_basic::components::{Button, ButtonVariant, ButtonSize};
if Button::new("Save")
.variant(ButtonVariant::Default)
.size(ButtonSize::Default)
.show(ui)
.clicked()
{
// handle click
}Implementations§
Source§impl Button
impl Button
Sourcepub const fn variant(self, variant: ButtonVariant) -> Self
pub const fn variant(self, variant: ButtonVariant) -> Self
Set the button variant
Sourcepub const fn size(self, size: ButtonSize) -> Self
pub const fn size(self, size: ButtonSize) -> Self
Set the button size
Sourcepub const fn full_width(self, full: bool) -> Self
pub const fn full_width(self, full: bool) -> Self
Make button take full width of container
Sourcepub const fn height(self, height: f32) -> Self
pub const fn height(self, height: f32) -> Self
Set explicit height (overrides size-based height)
Sourcepub const fn content_width(self, width: f32) -> Self
pub const fn content_width(self, width: f32) -> Self
Set explicit content area width for custom content buttons.
When using show_ui, this controls the inner width
available for the closure. If not set, defaults to a square (height-based) layout.
Sourcepub fn show_ui(
self,
ui: &mut Ui,
content: impl FnOnce(&mut Ui, &ContentContext),
) -> Response
pub fn show_ui( self, ui: &mut Ui, content: impl FnOnce(&mut Ui, &ContentContext), ) -> Response
Show the button with custom content instead of a text label.
The closure receives a &mut Ui (with override text color set) and a
ContentContext with the state-dependent color, font size, and active state.
Use content_width to control the inner width.
If not set, the button defaults to a square layout (width = height).
§Example
use armas_basic::components::{Button, ButtonVariant};
// Icon-only button (square)
Button::new("")
.variant(ButtonVariant::Ghost)
.show_ui(ui, |ui, ctx| {
ui.label("X");
});
// Icon + text button
Button::new("")
.content_width(80.0)
.show_ui(ui, |ui, ctx| {
// render_icon(ui.painter(), my_icon, ctx.color);
ui.label("Save");
});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
Mutably borrows from an owned value. Read more