Skip to main content

IconButton

Struct IconButton 

Source
pub struct IconButton<'a> { /* private fields */ }
Expand description

Icon Button component

size controls the total widget size (allocation), not the icon drawing area. The icon is drawn inside after subtracting padding. For Ghost/Link variants, padding defaults to 0 so size ≈ icon size. For other variants, padding defaults to ui.spacing().button_padding.

Implementations§

Source§

impl<'a> IconButton<'a>

Source

pub const fn new(icon_data: &'a IconData) -> Self

Create a new icon button from static IconData.

Source

pub fn from_owned(data: &'a OwnedIconData) -> Self

Create a new icon button from OwnedIconData.

Source

pub const fn variant(self, variant: ButtonVariant) -> Self

Set the button variant

Source

pub const fn size(self, size: f32) -> Self

Set the total widget size (icon + padding). Default 16.

Source

pub const fn padding(self, padding: f32) -> Self

Set padding between widget edge and icon. Default: 0 for Ghost/Link, button_padding for others.

Source

pub const fn enabled(self, enabled: bool) -> Self

Set enabled state

Source

pub const fn icon_color(self, color: Color32) -> Self

Set custom icon color (overrides default)

Source

pub const fn hover_icon_color(self, color: Color32) -> Self

Set custom hover icon color (overrides default)

Source

pub fn show(self, ui: &mut Ui) -> Response

Show the icon button

Auto Trait Implementations§

§

impl<'a> Freeze for IconButton<'a>

§

impl<'a> RefUnwindSafe for IconButton<'a>

§

impl<'a> Send for IconButton<'a>

§

impl<'a> Sync for IconButton<'a>

§

impl<'a> Unpin for IconButton<'a>

§

impl<'a> UnsafeUnpin for IconButton<'a>

§

impl<'a> UnwindSafe for IconButton<'a>

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.