iconify-rs

This crate provides a macro to embed SVGs from Iconify. For a list of icons, see Iconify Icon Sets.

Crates.io Crates.io docs.rs

📝 Usage

jsx let svg = iconify::svg!("mdi:home") iconify::svg! will download and embed an SVG as a string. It will also cache the request, so it won't download the same SVG twice. rust let svg = "<svg>...</svg>"

Templating

It can also be used directly in rsx, or any compile-time template engine.

Maud: rust html! { body { .card { (PreEscaped(iconify::svg!("mdi:home"))) p { "Hello!" } } } }

Askama (Currently, a bug prevents you from using the full macro path. See Issue #836)

jsx <body> <div class="card"> {{ svg!("mdi:home")|safe }} <p>Hello!</p> </body>

✨ Features

🔌 Offline Mode

If you don't want iconify-rs to make requests at compile-time in CI (or other reasons), you can use offline mode with prepared icons.

  1. Enable the offline feature.
  2. Prepare icons by setting ICONIFY_PREPARE=true and running cargo check. This will generate a directory for you in CARGO_MANIFEST_DIR called icons with all the icons you invoked.
  3. Now you're ready to go! Just run cargo build and it will use the icons you prepared.

If you want to set a custom directory, you can also set ICONIFY_OFFLINE_DIR.