23 stable releases

Uses new Rust 2024

new 16.8.0 Feb 8, 2026
16.6.1 Jan 25, 2026
16.3.0 Dec 28, 2025
16.0.0 Nov 30, 2025
0.0.1 Aug 11, 2025

#231 in Web programming

MIT AND CC0-1.0

5.5MB
24K SLoC

simpleicons-rs banner

simpleicons-rs

Access high‑quality Simple Icons SVGs directly from your Rust code.

Crates.io Docs MIT licensed

Overview

simpleicons-rs lets you fetch or embed SVGs from the Simple Icons collection in Rust:

  • Runtime lookup by slug.
  • Zero‑cost compile‑time constants (no lookup).
  • Optional color injection (brand default or any CSS color parseable by csscolorparser).

Installation

cargo add simpleicons-rs

Usage

[!IMPORTANT] Please read the legal disclaimer before using any icon.

function will return Icon as follow:

pub struct Icon {
    pub title: &'static str,
    pub slug: &'static str,
    pub hex: &'static str,
    pub source: &'static str,
    pub svg: &'static str,
}

Plain SVG

Use runtime lookup for flexibility, or a compile‑time constant for zero lookup:

use simpleicons_rs::{slug, SIRUST};

fn main() {
    let dynamic = slug("rust").unwrap(); // runtime lookup
    let constant = SIRUST;               // compile-time constant
    println!("{}", dynamic.svg);
    println!("{}", constant.svg);
}

Error handling:

match simpleicons_rs::slug("not-a-slug") {
    Some(icon) => println!("Found {}", icon.title),
    None => eprintln!("Icon not found"),
}

Colored SVG

use simpleicons_rs::slug_colored;

fn main() {
    let slug = "rust";

    // Official brand color
    let brand = slug_colored(slug, "default").unwrap();

    // CSS named color
    let named = slug_colored(slug, "black").unwrap();

    // Hex
    let hexed = slug_colored(slug, "#181717").unwrap();

    // Any csscolorparser format: #abc, rgb(), rgba(), hsl(), hsla(), etc.
    let hsl = slug_colored(slug, "hsl(10 10% 10%)").unwrap();

    println!("{}", brand.svg);
}

Build

This repo (builder) generates the publishable crate.

git clone https://github.com/cscnk52/simpleicons-rs.git
cd simpleicons-rs
cargo run

Generated crate appears under build/crates. Then:

cd build/crates
cargo publish --allow-dirty

License

  • simpleicons-rs: MIT and CC0-1.0.
  • simpleicons-rs-builder: MIT.
  • Simple Icons: CC0-1.0 and legal disclaimer.

Dependencies