Skip to content

Add cross-platform SVG fallback support #2

@AprilNEA

Description

@AprilNEA

Problem

Currently, when SF Symbols are not available (non-macOS platforms or older macOS versions), Icon::render() returns gpui::Empty, which means icons simply don't appear.

Proposed Solution

Add a fallback mechanism that allows specifying an alternative icon source:

// Option 1: Explicit fallback method
Icon::new("star.fill")
    .fallback_svg("icons/star.svg")
    .with_size(px(24.))

// Option 2: Builder with fallback
Icon::new("star.fill")
    .or_svg("icons/star.svg")
    .with_size(px(24.))

// Option 3: Automatic mapping via trait
impl SvgFallback for MyIcon {
    fn svg_path(&self) -> &'static str {
        match self {
            Self::Star => "icons/star.svg",
            // ...
        }
    }
}

Benefits

  • Cross-platform support (Linux, Windows)
  • Graceful degradation on older macOS versions
  • Better user experience when SF Symbols are unavailable

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions