Crates.io | iconify |
lib.rs | iconify |
version | 0.3.1 |
source | src |
created_at | 2023-07-05 07:36:56.454543 |
updated_at | 2024-04-20 07:41:56.870285 |
description | Proc-macros for generating icons from the Iconify API |
homepage | |
repository | https://github.com/wrapperup/iconify-rs |
max_upload_size | |
id | 908684 |
size | 39,838 |
This crate provides a macro to embed SVGs from Iconify. For a list of icons, see Iconify Icon Sets.
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>"
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.
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
<body>
<div class="card">
{{ iconify::svg!("mdi:home")|safe }}
<p>Hello!</p>
</body>
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.
offline
feature.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.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
.
ICONIFY_URL
- Sets the API url to use. If not set, the default is "https://api.iconify.design"ICONIFY_PREPARE
- If set, icons will be written to the offline icons directory (offline mode only)ICONIFY_OFFLINE_DIR
- Sets the offline icons directory. If not set, the default is "/icons" in your project directory