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.

Dispatches to the appropriate platform loader or bundled icon set based on the IconSet variant:

  • IconSet::Freedesktop – freedesktop theme lookup at 24 px using the system’s installed icon theme (requires system-icons feature, Linux only)
  • IconSet::SfSymbols – SF Symbols lookup (requires system-icons feature, macOS only)
  • IconSet::SegoeIcons – Segoe Fluent lookup (requires system-icons feature, Windows only)
  • IconSet::Material – bundled Material SVG (requires material-icons feature)
  • IconSet::Lucide – bundled Lucide SVG (requires lucide-icons feature)

Returns None when the required feature is not enabled, the platform doesn’t match, or the role has no icon in the requested set. There is no cross-set fallback – each set is self-contained.

§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());