pub struct Icon { /* private fields */ }Expand description
A decorative icon by default; .label exposes an independently meaningful image.
Named symbols and raw SVG data inherit text size and foreground, including disabled colors, from
their control’s icon slot. Outside a slot, use .size(px(24.)) for a 24dp icon.
Custom SVG paths use the application’s AssetSource. Mirroring is opt-in.
Implementations§
Source§impl Icon
impl Icon
Sourcepub fn new(symbol: IconName) -> Self
pub fn new(symbol: IconName) -> Self
Creates an icon from a bundled Material Symbols Outlined glyph.
Sourcepub fn svg(path: impl Into<SharedString>) -> Self
pub fn svg(path: impl Into<SharedString>) -> Self
Caller-provided SVG; retains the existing 24dp/OnSurfaceVariant defaults.
Sourcepub fn svg_data(data: impl Into<Arc<[u8]>>) -> Self
pub fn svg_data(data: impl Into<Arc<[u8]>>) -> Self
An in-memory SVG that inherits size and color from its icon slot.
Sourcepub fn custom(element: impl IntoElement) -> Self
pub fn custom(element: impl IntoElement) -> Self
Wraps an arbitrary caller-supplied element in a 24 dp icon container tinted to OnSurfaceVariant by default.
Sourcepub fn filled(self, filled: bool) -> Self
pub fn filled(self, filled: bool) -> Self
Select FILL=1 for a named symbol; does not alter caller-provided content.
Sourcepub fn label(
self,
id: impl Into<ElementId>,
name: impl Into<SharedString>,
) -> Self
pub fn label( self, id: impl Into<ElementId>, name: impl Into<SharedString>, ) -> Self
Exposes the icon as an independently meaningful Role::Image with the given accessible name.
Sourcepub fn size(self, side: Pixels) -> Self
pub fn size(self, side: Pixels) -> Self
Sets an explicit square side length in logical pixels (clamped to non-negative values).
Sourcepub fn color(self, color: ColorRole) -> Self
pub fn color(self, color: ColorRole) -> Self
Resolves the icon tint from the window theme’s semantic color role.
Sourcepub fn color_override(self, color: impl Into<Hsla>) -> Self
pub fn color_override(self, color: impl Into<Hsla>) -> Self
Sets a literal icon tint. A later call to Self::color or Self::inherit_color
replaces this override.
Sourcepub fn inherit_color(self) -> Self
pub fn inherit_color(self) -> Self
Clears any explicit color role or override so the icon inherits its parent text color (for example, inside buttons, navigation items, or surfaces).
Sourcepub fn mirror_in_rtl(self, mirror: bool) -> Self
pub fn mirror_in_rtl(self, mirror: bool) -> Self
Horizontally mirrors SVG icons when the window layout direction is right-to-left.
Trait Implementations§
Source§impl IntoElement for Icon
impl IntoElement for Icon
Source§type Element = ViewElement<Icon>
type Element = ViewElement<Icon>
Source§fn into_element(self) -> Self::Element
fn into_element(self) -> Self::Element
Element.Source§fn into_any_element(self) -> AnyElement
fn into_any_element(self) -> AnyElement
AnyElement.Source§impl RenderOnce for Icon
impl RenderOnce for Icon
Source§fn render(self, window: &mut Window, cx: &mut App) -> impl IntoElement
fn render(self, window: &mut Window, cx: &mut App) -> impl IntoElement
Render::render() method
which takes a mutable reference.Auto Trait Implementations§
impl !RefUnwindSafe for Icon
impl !Send for Icon
impl !Sync for Icon
impl !UnwindSafe for Icon
impl Forget for Icon
impl Freeze for Icon
impl Move for Icon
impl Unpin for Icon
impl UnsafeUnpin for Icon
Blanket Implementations§
Source§impl<E> AnimationExt for Ewhere
E: IntoElement + 'static,
impl<E> AnimationExt for Ewhere
E: IntoElement + 'static,
Source§fn with_animation(
self,
id: impl Into<ElementId>,
animation: Animation,
animator: impl Fn(Self, f32) -> Self + 'static,
) -> AnimationElement<Self>where
Self: Sized,
fn with_animation(
self,
id: impl Into<ElementId>,
animation: Animation,
animator: impl Fn(Self, f32) -> Self + 'static,
) -> AnimationElement<Self>where
Self: Sized,
Source§fn with_animations(
self,
id: impl Into<ElementId>,
animations: Vec<Animation>,
animator: impl Fn(Self, usize, f32) -> Self + 'static,
) -> AnimationElement<Self>where
Self: Sized,
fn with_animations(
self,
id: impl Into<ElementId>,
animations: Vec<Animation>,
animator: impl Fn(Self, usize, f32) -> Self + 'static,
) -> AnimationElement<Self>where
Self: Sized,
Source§fn with_spring<T>(
self,
id: impl Into<ElementId>,
animation: SpringAnimation<T>,
animator: impl FnOnce(Self, <T as SpringTarget>::Output) -> Self + 'static,
) -> SpringAnimationElement<Self>
fn with_spring<T>( self, id: impl Into<ElementId>, animation: SpringAnimation<T>, animator: impl FnOnce(Self, <T as SpringTarget>::Output) -> Self + 'static, ) -> SpringAnimationElement<Self>
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
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
impl<T> ErasedDestructor for Twhere
T: 'static,
Source§impl<T> FluentBuilder for Twhere
T: IntoElement,
impl<T> FluentBuilder for Twhere
T: IntoElement,
Source§fn map<U>(self, f: impl FnOnce(Self) -> U) -> Uwhere
Self: Sized,
fn map<U>(self, f: impl FnOnce(Self) -> U) -> Uwhere
Self: Sized,
Source§fn when(self, condition: bool, then: impl FnOnce(Self) -> Self) -> Selfwhere
Self: Sized,
fn when(self, condition: bool, then: impl FnOnce(Self) -> Self) -> Selfwhere
Self: Sized,
Source§fn when_else(
self,
condition: bool,
then: impl FnOnce(Self) -> Self,
else_fn: impl FnOnce(Self) -> Self,
) -> Selfwhere
Self: Sized,
fn when_else(
self,
condition: bool,
then: impl FnOnce(Self) -> Self,
else_fn: impl FnOnce(Self) -> Self,
) -> Selfwhere
Self: Sized,
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
Source§fn in_current_span(self) -> Instrumented<Self> ⓘ
fn in_current_span(self) -> Instrumented<Self> ⓘ
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> ⓘ
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> ⓘ
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 moreSource§impl<T> MaterialElementExt for Twhere
T: IntoElement,
impl<T> MaterialElementExt for Twhere
T: IntoElement,
Source§fn badge_label(self, text: impl Into<SharedString>) -> Badge
fn badge_label(self, text: impl Into<SharedString>) -> Badge
Badge to this element’s upper trailing edge.Source§fn badge_count(self, count: usize, maximum: usize) -> Badge
fn badge_count(self, count: usize, maximum: usize) -> Badge
Badge to this element’s upper trailing edge.Source§fn tooltip(
self,
id: impl Into<ElementId>,
text: impl Into<SharedString>,
) -> Tooltip
fn tooltip( self, id: impl Into<ElementId>, text: impl Into<SharedString>, ) -> Tooltip
Tooltip.Menu.Menu
whose items are built lazily only while the menu is open.Source§impl<T> Pointable for T
impl<T> Pointable for T
impl<T> Read<Exclusive, BecauseExclusive> for Twhere
T: ?Sized,
Source§impl<E> TestTextExt for Ewhere
E: IntoElement,
impl<E> TestTextExt for Ewhere
E: IntoElement,
Source§fn test_text(self, text: impl Into<SharedString>) -> Self::Element
fn test_text(self, text: impl Into<SharedString>) -> Self::Element
test-support, records text each time the element paints.
Otherwise returns the element it builds.Source§fn test_alt_text(self, text: impl Into<SharedString>) -> Self::Element
fn test_alt_text(self, text: impl Into<SharedString>) -> Self::Element
Self::test_text for an image’s alternative text, which
stands in for what the element draws.