pub struct Icon { /* private fields */ }Expand description
Declarative icon widget (Lucide, Devicon, or custom SVG).
For font glyphs, tint replaces the mask color.
For full-color SVGs, use Color::WHITE to preserve native colors.
The defaults are a 16-logical-pixel square, white tint, interactive tinting,
and zero rotation.
§Examples
use ailloli_ui_core::IconId;
use ailloli_ui_widgets::primitives::Icon;
let icon = Icon::new(IconId::Close).size(20.0);
let _ = icon;Implementations§
Source§impl Icon
impl Icon
Sourcepub fn width(self, value: impl Into<Length>) -> Self
pub fn width(self, value: impl Into<Length>) -> Self
Sets preferred width from a logical-pixel or length value.
§Examples
use ailloli_ui_core::IconId;
use ailloli_ui_widgets::primitives::Icon;
let widget = Icon::new(IconId::Close).width(24.0);
let _ = widget;Sourcepub fn height(self, value: impl Into<Length>) -> Self
pub fn height(self, value: impl Into<Length>) -> Self
Sets preferred height from a logical-pixel or length value.
§Examples
use ailloli_ui_core::IconId;
use ailloli_ui_widgets::primitives::Icon;
let widget = Icon::new(IconId::Close).height(24.0);
let _ = widget;Sourcepub fn min_width(self, value: impl Into<Length>) -> Self
pub fn min_width(self, value: impl Into<Length>) -> Self
Sets the minimum width bound.
§Examples
use ailloli_ui_core::IconId;
use ailloli_ui_widgets::primitives::Icon;
let widget = Icon::new(IconId::Close).min_width(12.0);
let _ = widget;Sourcepub fn max_width(self, value: impl Into<Length>) -> Self
pub fn max_width(self, value: impl Into<Length>) -> Self
Sets the maximum width bound.
§Examples
use ailloli_ui_core::IconId;
use ailloli_ui_widgets::primitives::Icon;
let widget = Icon::new(IconId::Close).max_width(32.0);
let _ = widget;Sourcepub fn min_height(self, value: impl Into<Length>) -> Self
pub fn min_height(self, value: impl Into<Length>) -> Self
Sets the minimum height bound.
§Examples
use ailloli_ui_core::IconId;
use ailloli_ui_widgets::primitives::Icon;
let widget = Icon::new(IconId::Close).min_height(12.0);
let _ = widget;Sourcepub fn max_height(self, value: impl Into<Length>) -> Self
pub fn max_height(self, value: impl Into<Length>) -> Self
Sets the maximum height bound.
§Examples
use ailloli_ui_core::IconId;
use ailloli_ui_widgets::primitives::Icon;
let widget = Icon::new(IconId::Close).max_height(32.0);
let _ = widget;Sourcepub fn fill(self) -> Self
pub fn fill(self) -> Self
Sets both preferred axes to parent fill.
§Examples
use ailloli_ui_core::IconId;
use ailloli_ui_widgets::primitives::Icon;
let widget = Icon::new(IconId::Close).fill();
let _ = widget;Sourcepub fn fill_width(self) -> Self
pub fn fill_width(self) -> Self
Sets preferred width to parent fill.
§Examples
use ailloli_ui_core::IconId;
use ailloli_ui_widgets::primitives::Icon;
let widget = Icon::new(IconId::Close).fill_width();
let _ = widget;Sourcepub fn fill_height(self) -> Self
pub fn fill_height(self) -> Self
Sets preferred height to parent fill.
§Examples
use ailloli_ui_core::IconId;
use ailloli_ui_widgets::primitives::Icon;
let widget = Icon::new(IconId::Close).fill_height();
let _ = widget;Sourcepub fn margin(self, value: f32) -> Self
pub fn margin(self, value: f32) -> Self
Sets uniform outer margin in logical pixels.
§Examples
use ailloli_ui_core::IconId;
use ailloli_ui_widgets::primitives::Icon;
let widget = Icon::new(IconId::Close).margin(4.0);
let _ = widget;Sourcepub fn padding(self, value: f32) -> Self
pub fn padding(self, value: f32) -> Self
Sets uniform inner padding in logical pixels.
§Examples
use ailloli_ui_core::IconId;
use ailloli_ui_widgets::primitives::Icon;
let widget = Icon::new(IconId::Close).padding(4.0);
let _ = widget;Sourcepub fn flex_grow(self) -> Self
pub fn flex_grow(self) -> Self
Sets flex-grow weight to one.
§Examples
use ailloli_ui_core::IconId;
use ailloli_ui_widgets::primitives::Icon;
let widget = Icon::new(IconId::Close).flex_grow();
let _ = widget;Sourcepub fn flex_grow_by(self, value: f32) -> Self
pub fn flex_grow_by(self, value: f32) -> Self
Sets a dimensionless flex-grow weight.
§Examples
use ailloli_ui_core::IconId;
use ailloli_ui_widgets::primitives::Icon;
let widget = Icon::new(IconId::Close).flex_grow_by(2.0);
let _ = widget;Sourcepub fn flex_shrink(self, value: f32) -> Self
pub fn flex_shrink(self, value: f32) -> Self
Sets a dimensionless flex-shrink weight.
§Examples
use ailloli_ui_core::IconId;
use ailloli_ui_widgets::primitives::Icon;
let widget = Icon::new(IconId::Close).flex_shrink(1.0);
let _ = widget;Sourcepub fn flex_basis(self, value: impl Into<Length>) -> Self
pub fn flex_basis(self, value: impl Into<Length>) -> Self
Sets the preferred main-axis flex basis.
§Examples
use ailloli_ui_core::IconId;
use ailloli_ui_widgets::primitives::Icon;
let widget = Icon::new(IconId::Close).flex_basis(20.0);
let _ = widget;Sourcepub fn align_self(self, value: AlignItems) -> Self
pub fn align_self(self, value: AlignItems) -> Self
Overrides cross-axis alignment for this flex item.
§Examples
use ailloli_ui_core::{style::AlignItems, IconId};
use ailloli_ui_widgets::primitives::Icon;
let widget = Icon::new(IconId::Close).align_self(AlignItems::Center);
let _ = widget;Source§impl Icon
impl Icon
Sourcepub fn new(source: impl Into<IconId>) -> Self
pub fn new(source: impl Into<IconId>) -> Self
Creates a default icon from any [IconId]-compatible source.
§Examples
use ailloli_ui_core::IconId;
use ailloli_ui_widgets::primitives::Icon;
let icon = Icon::new(IconId::Check);
let _ = icon;Sourcepub fn lucide(icon: LucideIcon) -> Self
pub fn lucide(icon: LucideIcon) -> Self
Creates a Lucide font-glyph icon.
§Examples
use ailloli_ui_widgets::primitives::Icon;
let icon = Icon::lucide(lucide_icons::Icon::Plus);
let _ = icon;Sourcepub fn devicon(ch: char) -> Self
pub fn devicon(ch: char) -> Self
Creates a Devicon font glyph from its Unicode scalar.
The glyph is not checked against the bundled font at construction.
§Examples
use ailloli_ui_widgets::primitives::Icon;
let icon = Icon::devicon('\u{e7a8}');
let _ = icon;Sourcepub fn svg_static(bytes: &'static [u8]) -> Self
pub fn svg_static(bytes: &'static [u8]) -> Self
Creates an SVG icon borrowing compile-time-static bytes.
Bytes are retained and validated only by a renderer/cache when used.
§Examples
use ailloli_ui_widgets::primitives::Icon;
let icon = Icon::svg_static(b"<svg/>");
let _ = icon;Sourcepub fn svg_bytes(bytes: impl Into<Arc<[u8]>>) -> Self
pub fn svg_bytes(bytes: impl Into<Arc<[u8]>>) -> Self
Creates an SVG icon from shared owned bytes.
§Examples
use std::sync::Arc;
use ailloli_ui_widgets::primitives::Icon;
let icon = Icon::svg_bytes(Arc::<[u8]>::from(&b"<svg/>"[..]));
let _ = icon;Sourcepub fn svg_str(s: impl Into<Arc<str>>) -> Self
pub fn svg_str(s: impl Into<Arc<str>>) -> Self
Creates an SVG icon from shared UTF-8 markup.
§Examples
use std::sync::Arc;
use ailloli_ui_widgets::primitives::Icon;
let icon = Icon::svg_str(Arc::<str>::from("<svg/>"));
let _ = icon;Sourcepub fn tint(self, color: Color) -> Self
pub fn tint(self, color: Color) -> Self
Replaces the render tint.
Use [Color::WHITE] to preserve a full-color SVG.
§Examples
use ailloli_ui_core::{Color, IconId};
use ailloli_ui_widgets::primitives::Icon;
let icon = Icon::new(IconId::Close).tint(Color::rgba(255, 0, 0, 1.0));
let _ = icon;Sourcepub fn size(self, px: f32) -> Self
pub fn size(self, px: f32) -> Self
Sets the square extent in logical pixels, clamped to at least zero.
Non-finite values follow f32::max; a NaN therefore resolves to
zero while positive infinity remains unbounded for later constraints.
§Examples
use ailloli_ui_core::IconId;
use ailloli_ui_widgets::primitives::Icon;
let icon = Icon::new(IconId::Close).size(-4.0);
let _ = icon;Sourcepub fn interactive_tint(self, enabled: bool) -> Self
pub fn interactive_tint(self, enabled: bool) -> Self
Enables or disables automatic hover/pressed tint adjustments.
Disable this for full-color brand artwork.
§Examples
use ailloli_ui_core::IconId;
use ailloli_ui_widgets::primitives::Icon;
let icon = Icon::new(IconId::Close).interactive_tint(false);
let _ = icon;Sourcepub fn rotation_rad(self, radians: f32) -> Self
pub fn rotation_rad(self, radians: f32) -> Self
Sets clockwise renderer rotation in radians.
NaN and either infinity are replaced with zero; finite angles are not
normalized and may exceed one full turn.
§Examples
use ailloli_ui_core::IconId;
use ailloli_ui_widgets::primitives::Icon;
let icon = Icon::new(IconId::Close).rotation_rad(std::f32::consts::FRAC_PI_2);
let _ = icon;