icon

Function icon 

Source
pub fn icon(args: impl Into<IconArgs>)
Expand description

§icon

Renders an icon with consistent sizing and optional tinting for vectors.

§Usage

Display a vector or raster image with a uniform size, often inside a button or as a status indicator.

§Parameters

  • args — configures the icon’s content, size, and tint; see IconArgs.

§Examples

use std::sync::Arc;
use tessera_ui::Color;
use tessera_ui_basic_components::{
    icon::{icon, IconArgsBuilder},
    image_vector::{ImageVectorSource, load_image_vector_from_source},
};

// Load vector data from an SVG file.
// In a real app, this should be done once and the data cached.
let svg_path = "../assets/emoji_u1f416.svg";
let vector_data = load_image_vector_from_source(
    &ImageVectorSource::Path(svg_path.to_string())
).unwrap();

icon(
    IconArgsBuilder::default()
        .content(vector_data)
        .tint(Color::new(0.2, 0.5, 0.8, 1.0))
        .build()
        .unwrap(),
);