Skip to main content

load_icon

Function load_icon 

Source
pub fn load_icon(role: IconRole, icon_set: &str) -> 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. Parse icon_set to IconSet (unknown names fall back to system set)
  2. Platform loader (freedesktop/sf-symbols/segoe-fluent) when system-icons enabled
  3. Bundled SVGs (material/lucide) when the corresponding feature is enabled
  4. Non-matching set: None (no cross-set fallback)

§Examples

use native_theme::{load_icon, IconRole};

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