limn
    ↑↓ ChooseEnter OpenEsc Close
    GitHub

    Components/System

    Icon

    A semantic icon name, such as Icon::Trash or Icon::Search. Components take an Icon and the backend chooses the artwork, which is Bootstrap Icons unless the host gives another set.

    Native componentGuide source

    Preview

    CodeSource
    fn view(palette: ComponentPalette) -> Element {
        Element::row(vec![
            Element::icon(Icon::Search).foreground(palette.muted),
            Button::new("open", "Open", palette).icon(Icon::Folder).render(),
        ])
    }

    Examples

    Each one is the library drawing it. Press, type and hover.

    Servers and settings
    CodeSource
    row(
        [
            (Icon::Lock, "Lock"),
            (Icon::Neutral, "Neutral"),
            (Icon::ChevronUp, "ChevronUp"),
            (Icon::Invite, "Invite"),
            (Icon::Leave, "Leave"),
            (Icon::DragHandle, "DragHandle"),
        ]
        .into_iter()
        .flat_map(|(icon, name)| [
            Element::icon(icon).foreground(palette.text),
            caption(cx, name),
            Element::spacer().size(Some(8.0), None),
        ])
        .collect(),
    )
    Categories and small icons1 / 2
    CodeSource
    row(
        [
            (Icon::Emoji, "Emoji"),
            (Icon::Tree, "Tree"),
            (Icon::FriedEgg, "FriedEgg"),
            (Icon::Gamepad, "Gamepad"),
            (Icon::Car, "Car"),
            (Icon::Lightbulb, "Lightbulb"),
            (Icon::Heart, "Heart"),
            (Icon::Flag, "Flag"),
        ]
        .into_iter()
        .flat_map(|(icon, name)| [
            Element::icon(icon).large_icon(20.0).foreground(palette.text),
            caption(cx, name),
            Element::spacer().size(Some(8.0), None),
        ])
        .collect(),
    )
    Categories and small icons2 / 2
    CodeSource
    row(vec![
        // A padlock over the corner of a channel's glyph.
        Element::stack(vec![
            Element::icon(Icon::Hash).large_icon(20.0).foreground(palette.text),
            Element::column(vec![
                Element::row(vec![
                    Element::spacer().flex(1.0),
                    Element::icon(Icon::Lock).small_icon(10.0).foreground(palette.text),
                ]),
                Element::spacer().flex(1.0),
            ]),
        ])
        .size(Some(20.0), Some(20.0)),
        caption(cx, "small_icon(10)"),
        Element::icon(Icon::Volume).small_icon(12.0).foreground(palette.text),
        caption(cx, "small_icon(12)"),
        Element::icon(Icon::Volume).small_icon(8.0).foreground(palette.text),
        caption(cx, "small_icon(8)"),
    ])

    Icon

    A semantic icon name, such as Icon::Trash or Icon::Search. Components take an Icon and the backend chooses the artwork, which is Bootstrap Icons unless the host gives another set.

    Import

    use limn::{Element, Icon};

    Icon is an enum, not a component: it has no render.

    Usage

    Pass an icon to the component that shows it, or paint one on its own with Element::icon, which draws it at 16 px in the element’s foreground.

    fn view(palette: ComponentPalette) -> Element {
        Element::row(vec![
            Element::icon(Icon::Search).foreground(palette.muted),
            Button::new("open", "Open", palette).icon(Icon::Folder).render(),
        ])
    }

    The chosen item

    let icon = if chosen { Icon::Folder.filled() } else { Icon::Folder };
    Element::icon(icon).foreground(if chosen { palette.text } else { palette.muted })

    filled() returns the solid form of an icon, for the active or chosen item of a list. An icon without one, such as Icon::Search, is returned as it is.

    Larger

    Element::icon(Icon::Folder).large_icon(48.0)

    large_icon(px) draws a standalone icon larger than 16 px, up to 128, for thumbnails and empty states. Icons inside controls keep 16 px.

    Smaller

    Element::icon(Icon::Lock).small_icon(10.0)

    small_icon(px) draws a standalone icon smaller than 16 px, down to SMALL_ICON_SIZE (8), such as a padlock over a corner of another icon or a speaker inside a small badge. The element measures the side it is drawn at.

    Categories

    Icon::Tree, FriedEgg, Gamepad, Car, Lightbulb and Flag, with Emoji and Heart, name the usual categories of an emoji picker: nature, food, activities, travel, objects and flags, people and symbols.

    File types

    Element::icon(file_icon("src/main.rs"))

    file_icon(path) returns the artwork for a file’s type. These icons keep their own colors.

    Artwork of your own

    const LOGO: &str = include_str!("../assets/logo.svg");
    Element::icon(Icon::Custom(LOGO)).foreground(palette.text)

    Icon::Custom takes the source of an SVG drawn with currentColor. It is fitted to the icon’s square without distortion and tinted like any other icon.

    Another icon set

    fn lucide(icon: Icon) -> Option<&'static str> {
        match icon {
            Icon::Search => Some(include_str!("../assets/lucide/search.svg")),
            Icon::Trash => Some(include_str!("../assets/lucide/trash-2.svg")),
            _ => None,
        }
    }
    
    limn_egui::set_icon_pack(lucide);

    A pack is a function from an Icon to the SVG that draws it, or None to leave that one to Bootstrap Icons, so it can replace a few icons or all of them. The artwork must draw with currentColor. Call set_icon_pack once on the UI thread when the window is created, before the first frame: an icon already drawn stays as it was. File type icons and Icon::Custom are not asked of the pack.

    Platform-rendered icons

    A host can render system artwork, such as SF Symbols on iOS, without converting it to SVG. Supply a function with this signature:

    fn render_platform_icon(icon: Icon, pixels: u16) -> Option<eframe::egui::ColorImage>

    Install it on the UI thread with limn_egui::set_icon_rasterizer(Some(render_platform_icon)). It receives the final physical pixel side, including display scaling. Return a square image of that exact size containing a white alpha mask; the painter applies the element’s color. Native premultiplied RGBA bytes can be converted with ColorImage::from_rgba_premultiplied.

    Return None for an unsupported symbol or for application artwork that should remain unchanged. A missing or malformed image uses the configured SVG pack, then the usual bundled artwork. The rasterizer can explicitly handle Icon::Custom; file-type icons always keep their original colors.

    The normal bounded texture cache reuses each icon at each physical size. Replacing the renderer, or removing it with set_icon_rasterizer(None), clears only cached icon textures and requests a repaint. Raster images and the application’s own artwork data remain in their separate caches.

    See Icons in the component reference.

    API reference

    The guide covers composition, options and actions. Generate the complete Rust type and builder reference from the checkout:

    cargo doc -p limn --open

    Component API overview · State and actions

    The example is drawn by crates/limn-gallery/src/pages/navigation.rs.