pub struct Button<'a> { /* private fields */ }Expand description
A button widget with support for semantic variants
Button provides distinct visual variants that communicate different levels of importance and action types.
§Example
use egui_charts::icons::icons;
use egui_charts::ui_kit::buttons::Button;
// Primary button (high emphasis)
if Button::new("Save Changes").primary().show(ui).clicked() {
// save
}
// Ghost button with icon (low emphasis)
Button::icon_and_text(&icons::SETTINGS, "Settings")
.ghost()
.show(ui);
// Danger button (destructive action)
Button::new("Delete")
.danger()
.show(ui);Implementations§
Source§impl<'a> Button<'a>
impl<'a> Button<'a>
Sourcepub fn icon_and_text(icon: &'a Icon, text: impl Into<String>) -> Self
pub fn icon_and_text(icon: &'a Icon, text: impl Into<String>) -> Self
Create a new button with both icon and text
Sourcepub fn variant(self, variant: ButtonVariant) -> Self
pub fn variant(self, variant: ButtonVariant) -> Self
Set the button variant
Sourcepub fn text_color(self, color: Color32) -> Self
pub fn text_color(self, color: Color32) -> Self
Override only the label colour, retaining the variant’s fill and icon colour.
Sourcepub fn size(self, size: ButtonSize) -> Self
pub fn size(self, size: ButtonSize) -> Self
Set the button size
Sourcepub fn icon_scale(self, scale: f32) -> Self
pub fn icon_scale(self, scale: f32) -> Self
Set the icon size as a fraction of the button height (0.1-1.0).
By default the icon is 16, 20 or 24 px for small, medium and larger buttons.
Trait Implementations§
Auto Trait Implementations§
impl<'a> Freeze for Button<'a>
impl<'a> RefUnwindSafe for Button<'a>
impl<'a> Send for Button<'a>
impl<'a> Sync for Button<'a>
impl<'a> Unpin for Button<'a>
impl<'a> UnsafeUnpin for Button<'a>
impl<'a> UnwindSafe for Button<'a>
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
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
Converts
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
Converts
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more