Skip to content

About

autogenerated phosphor icons exported as a bunch of `const &str`s

Resources

Stars

1 star

Watchers

1 watching

Forks

Latest commit

 

History

62 Commits

Folders and files

Repository files navigation

phosphor-svgs

All the SVGs from Phosphor Icons, autogenerated, and exported as const &strs.

Usage

All icons are available, sorted by either style or icon:

// by style
use phosphor_svgs::style::regular::CHECK_CIRCLE;
use phosphor_svgs::style::bold::ALARM;

// by icon
use phosphor_svgs::icon::check_circle::REGULAR;
use phosphor_svgs::icon::alarm::BOLD;

Usage with Leptos

Components for Leptos v0.8 are available under the leptos-0-8 feature. These components are styled with plain CSS (or tailwind or some other styling library).

Every icon is exported as a struct in the leptos::icons module, and weights are exported from leptos::weights module:

use leptos::prelude::*;
use phosphor_svgs::leptos::Icon;
use phosphor_svgs::leptos::icons::{ Alarm, CheckCircle };
use phosphor_svgs::leptos::weights::{ Bold, Regular };

#[component]
pub fn MyComponent() -> impl IntoView {
   view! {
      // There are two ways to specify icons:

      // as props...
      <Icon icon=CheckCircle weight=Regular style:height="32px" style:color="red" />

      // ... or as generics...
      <Icon<CheckCircle, Regular> style:height="32px" style:color="red" />

      // tailwindcss example
      <Icon<Alarm, Bold> attr:class="h-8 fill-red-300" />

      // unlike the source icons, we don't set fill="currentColor" for more flexibility
      <Icon<Alarm, Bold> attr:class="h-8 fill-current text-red-300" />
   }
}

The Icon component is designed to be statically typed to the component and weight to help ensure that unused icon data isn't included needlessly. If you need to reactively change icons, consider to wrap seperate instances of components in Either or convert them into AnyView using into_any():

use leptos::prelude::*;
use leptos::either::Either;
use phosphor_svgs::leptos::Icon;
use phosphor_svgs::leptos::icons::{ Alarm, CheckCircle };
use phosphor_svgs::leptos::weights::{ Bold, Regular };

let (condition, _) = signal(false);
let icon_either = move || if *condition.read() {
   Either::Left(view! { <Icon<CheckCircle, Regular> /> })
} else {
   Either::Right(view! { <Icon<Alarm, Bold> /> })
};
let icon_any = move || if *condition.read() {
   view! { <Icon<CheckCircle, Regular> /> }.into_any()
} else {
   view! { <Icon<Alarm, Bold> /> }.into_any()
};

view! {
   {icon_either}
   {icon_any}
}

License

Phosphor Icons © 2023 Phosphor Icons, used under MIT license
phosphor-svgs © 2024-2026 Meadowsys, licensed under MIT license

About

autogenerated phosphor icons exported as a bunch of `const &str`s

Resources

Stars

1 star

Watchers

1 watching

Forks

Releases

Packages

Used by

Contributors

Languages