Skip to main content

Crate pictogram

Crate pictogram 

Source
Expand description

§Pictogram

Pictogram resolves icons at compile time using data stored in the manifest directory. During compilation an icon is looked up and baked into your application. This bypasses compilation penalties as the entire icon data does not have to be compiled by rustc.

§Features

  • Support for many libraries: See supported libraries for more information.
  • Type-Safe: If an icon can’t be resolved, it will lead to a compilation error.
  • Compile-Time: Icons are baked into your code at compile time.
  • Only pay for what you need: Only compile the icons, you actually use.
  • Framework independent: Although, there is an adapter for dioxus.
  • NOT vibe coded.

§How to use it

# By default all features are enabled
pictogram = { version = "*", features=["material"] }
let svg = pictogram::svg!(pictogram::material::action_123::filled);
println!("{}", svg);

§Dioxus adapter

The adapter is available here.

// Define icons locally - from the index
define_icon!(pictogram::material::social_person::filled);
// Or from your local assets
define_icon!(CustomIcon, "local-path-to-custom-icon.svg");

#[component]
fn SomeComponent() -> Element {
  rsx! {
      // Or use the general component
      Icon {
          icon: pictogram::svg!(pictogram::material::image_crop_free::outlined),
          width: "3rem",
          height: "3rem",
          // Compose icons
          SocialPersonFilled {
            height: 16,
            width: 16,
            x: 4,
            y: 4
        }
      }
      CustomIcon {
        width: "3rem",
        height: "3rem"
      }
  }
}

§Supported libraries

Feel free to make a PR to add more libraries or ask for it in an issue.

LibraryFeatureLicenseCrate
Material design iconsmaterialApache-2.0material
BootstrapbootstrapMITbootstrap
FeatherfeatherMITfeather
Font Awesomefont-awesomeCC BY 4.0font-awesome
TablertablerMITtabler
SimplesimpleCC0-1.0simple
HeroiconsheroMIThero
IoniconsionMITion
LucidelucidISClucide
Primer OcticonsoctMIToct
Vscode CodiconsvscodeCC BY 4.0vscode

§License

This project is licensed under either

at your option.

§Icon Licenses

All icons are licensed under their respective licenses. Please contact me, if any repository would like to be removed/updated.

Modules§

bootstrap
Index to lookup available icons from bootstrap Exports the index of the available icons
feather
Index to lookup available icons from feather Exports the index of the available icons
font_awesome
Index to lookup available icons from font awesome Exports the index of the available icons
hero
Index to lookup available icons from heroicons Exports the index of the available icons
ion
Index to lookup available icons from ion Exports the index of the available icons
lucide
Index to lookup available icons from lucide Exports the index of the available icons
material
Index to lookup available icons from material Exports the index of the available icons
oct
Index to lookup available icons from oct Exports the index of the available icons
simple
Index to lookup available icons from simple Exports the index of the available icons
tabler
Index to lookup available icons from tabler Exports the index of the available icons
vscode
Index to lookup available icons from vscode Exports the index of the available icons

Macros§

svg
Macro to lookup a SVG at compile time. Wraps the proc-macro for better ergonomics.

Structs§

Svg
The emitted SVG by the macro! Right now only xmlns and viewBox are extracted. The body is just extracted as a whole.
SvgParseError
ViewBox
ViewBox auf the SVG