simpleicons-rs

Crates.iosimpleicons-rs
lib.rssimpleicons-rs
version16.6.1
created_at2025-08-11 07:52:32.069208+00
updated_at2026-01-25 00:49:12.825664+00
descriptionSVG icons for popular brands
homepage
repositoryhttps://github.com/cscnk52/simpleicons-rs
max_upload_size
id1789721
size5,635,690
Cason Kervis (cscnk52)

documentation

README

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.
Commit count: 112

cargo fmt