Proc-macros for generating icons from the Iconify API

Overview

iconify-rs

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

📝 Usage

let svg = iconify::svg!("mdi:home", color = "red")

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.

let svg = "<svg>...</svg>"

Options

You can pass options to the macro to customize the SVG.

let svg = iconify::svg!("mdi:home",
    width = "24",
    height = "24",
    color = "red",
    // ... and more.
)

All options from the Iconify API are supported. You can find the documentation for the options for the svg! macro here.

Templating

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

Maud:

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)

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

Features

  • Directly embed SVGs from Iconify
  • Caches requests (default feature)
  • Offline mode
  • SVG transforms (through API)
  • (Soon) CSS fetching

🔌 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.

You might also like...
List public items (public API) of Rust library crates. Enables diffing public API between releases.

cargo wrapper for this library You probably want the cargo wrapper to this library. See https://github.com/Enselic/cargo-public-items. public_items Li

Uma lib para a API do Brasil API (para o Rust)
Uma lib para a API do Brasil API (para o Rust)

Uma lib para a API do BrasilAPI (para o Rust) Features CEP (Zip code) DDD Bank CNPJ IBGE Feriados Nacionais Tabela FIPE ISBN Registros de domínios br

Rust library for hardware accelerated drawing of 2D shapes, images, and text, with an easy to use API.
Rust library for hardware accelerated drawing of 2D shapes, images, and text, with an easy to use API.

Speedy2D Hardware-accelerated drawing of shapes, images, and text, with an easy to use API. Speedy2D aims to be: The simplest Rust API for creating a

An API for getting questions from http://either.io implemented fully in Rust, using reqwest and some regex magic. Provides asynchronous and blocking clients respectively.

eithers_rust An API for getting questions from http://either.io implemented fully in Rust, using reqwest and some regex magic. Provides asynchronous a

Code to follow along the "Zero To Production" book on API development in Rust.

Zero To Production / Code (Chapter 10 - Part 1) Zero To Production In Rust is an opinionated introduction to backend development using Rust. This repo

Interact with the crate's API

cargo-crate-api Interact with the crate's API Documentation Installation Getting Started Reference FAQ Contribute CHANGELOG Install Download a pre-bui

Conversion Tools API Rust client

ConversionTools Rust This Conversion Tools API Rust client allows you to use the site API and convert files faster and more conveniently. Site Convers

Public aircraft & flightroute api Built in Rust for Docker, using PostgreSQL & Redis

api.adsbdb.com public aircraft & flightroute api Built in Rust for Docker, using PostgreSQL & Redis See typescript branch for original typescript vers

Simple RESTful API in rust created with actix-web. (Routing, models, JWT auth).

rust-simple-api Simple RESTful API created with rust, actix-web, Diesel, JWT. Running application Manual Firstly generate a secret.key which will be u

Comments
  • Replace `reqwest` with `ureq`, bump versions

    Replace `reqwest` with `ureq`, bump versions

    This reduces the number of dependencies iconify-rs pulls in by quite a bit. reqwest depended on Tokio, which we don't make use of at all.

    If you don't require tls or caching, you can also disable the default features to reduce the dependencies further.

    opened by wrapperup 0
Owner
Matthew Taylor
Animation Engineer @ 1047 Games  Web Dev / Tech Artist @ Brickadia
Matthew Taylor
A simple /proc//{mem,maps} library for Rust

Summary A very simple library that wraps around /proc/pid/mem and /proc/pid/maps to read memory out of a running process on Linux. Usage Basic usage l

null 6 Jul 27, 2022
Proc macro implementation of #[naked]

#[naked] Documentation This crate provide a proc macro version of the #[naked] attribute which can be used on stable Rust. Example // The SYSV64 calli

Amanieu d'Antras 10 Aug 13, 2022
Library and proc macro to analyze memory usage of data structures in rust.

Allocative: memory profiler for Rust This crate implements a lightweight memory profiler which allows object traversal and memory size introspection.

Meta Experimental 19 Jan 6, 2023
proc-macro to help with using surrealdb's custom functions

SurrealDB Functions This is a proc-macro crate that given a path to a .surql file or a folder of .surql files, will parse DEFINE FUNCTION fn::s inside

Aly 5 Jul 30, 2023
Lazy Sieve of Eratosthenes for infinitely generating primes lazily in Rust.

lazy-prime-sieve Lazy Sieve of Eratosthenes for infinitely generating primes lazily in Rust. Usage lazy-prime-sieve is a library crate. You may add it

Arindam Das 2 Jul 13, 2023
Learn to write Rust procedural macros [Rust Latam conference, Montevideo Uruguay, March 2019]

Rust Latam: procedural macros workshop This repo contains a selection of projects designed to learn to write Rust procedural macros — Rust code that g

David Tolnay 2.5k Dec 29, 2022
Attribute for defining `macro_rules!` macros with proper visibility and scoping

macro-vis This crate provides an attribute for defining macro_rules! macros that have proper visibility and scoping. The default scoping and publicity

null 2 Aug 29, 2022
A Rust crate providing utility functions and macros.

介绍 此库提供四类功能:异常处理、http post收发对象、格式转换、语法糖。 在 Cargo.toml 里添加如下依赖项 [dependencies.xuanmi_base_support] git = "https://github.com/taiyi-research-institute/x

null 17 Mar 22, 2023
Linux daemon to bind keys and macros to your controller's buttons

makima Makima is a daemon for Linux to bind your controller's buttons to key sequences and macros. Features: Configure your keybindings through a simp

null 48 Jun 14, 2023
Tiny macros for bailing on failure

tiny_bail Bailing is an error-handling pattern that takes the middle path between unwrap and ?: Compared to unwrap: Bail will return, continue, or bre

Ben Frankel 22 Sep 10, 2024