Skip to main content

load_icon

Function load_icon 

Source
pub fn load_icon(role: IconRole, set: IconSet) -> Option<IconData>
Expand description

Load an icon for the given role using the specified icon set.

Resolves icon_set to an IconSet via IconSet::from_name(), falling back to system_icon_set() if the set string is not recognized. Then dispatches to the appropriate platform loader or bundled icon set.

§Dispatch

  1. Platform loader (freedesktop/sf-symbols/segoe-fluent) when system-icons enabled
  2. Bundled SVGs (material/lucide) when the corresponding feature is enabled
  3. Non-matching set: None (no cross-set fallback)

Freedesktop icons are loaded at 24 px (the standard toolbar size). For custom sizes, call freedesktop::load_freedesktop_icon() directly.

§Examples

use native_theme::{load_icon, IconRole, IconSet};

// With material-icons feature enabled
let icon = load_icon(IconRole::ActionCopy, IconSet::Material);
assert!(icon.is_some());