PulsoIcon

PulsoIcon for Astro

pulsoicon.com: browse all icons, try them live and copy the code

9955 animated icons. Every one has its own motion.

npm version license

---

PulsoIcon icons animating on hover

Astro components for icons that play their own motion when someone hovers or focuses the button, link or tab they sit in. The `` is rendered on the server, with no framework island; each icon on the page adds one small script that brings its motion. They render exactly the same `` as `pulsoicon-react` and move the same way. ## Install ```bash npm install pulsoicon-astro ``` Works with Astro 5 or newer. [Motion](https://motion.dev) (12 or newer) plays the icons; npm installs it for you. ## Quick start ```astro --- import Bell from "pulsoicon-astro/icons/bell"; import Calendar from "pulsoicon-astro/icons/calendar"; import Trash2 from "pulsoicon-astro/icons/trash-2"; --- ``` Hover a button and its icon plays. Named imports work too (`import { Bell } from "pulsoicon-astro"`), but importing each icon from `pulsoicon-astro/icons/` keeps the dev server from compiling all 9955 components. ## Props The same names, defaults and meaning as in every PulsoIcon package. | Prop | Type | Default | Description | | --------------------- | ------------------ | -------------- | ----------------------------------------------------------------------------------------------- | | `size` | `number \| string` | `24` | Width and height | | `color` | `string` | `currentColor` | Stroke colour, and fill colour when `solid` | | `strokeWidth` | `number \| string` | `2` | Stroke width on the 24-unit grid | | `absoluteStrokeWidth` | `boolean` | `false` | Keep the stroke the same number of pixels at any size | | `solid` | `boolean` | `false` | Filled icon instead of outline | | `animated` | `boolean` | `true` | `false` makes the icon fully static: nothing plays it, not even `getIconHandle` | | `autoAnimated` | `boolean` | `true` | Play the built-in hover / focus trigger. `false` turns that off; `getIconHandle` still plays it | Any other attribute (`class`, `style`, `id`, `aria-label`, …) goes on the ``. Icons render with `aria-hidden="true"`; give the surrounding button or link a label. ## When the animation plays An icon plays when the pointer enters, or focus moves into, its closest `button`, `a`, `label`, `summary`, `[role="button"]`, `[role="link"]`, `[role="tab"]` or `[role="menuitem"]`. If there is none, the icon plays on its own hover. Any other element becomes the trigger with `data-icon-trigger`. Nothing moves when the system asks for reduced motion. Icons keep working across page swaps with Astro's view transitions. ### Play from code Astro components don't run in the browser, so a `play` prop can't change after render. In a client script, `getIconHandle(svg)` from `pulsoicon-astro/client` gives `startAnimation()` and `stopAnimation()`; both return a promise that resolves when the motion has finished: ```astro --- import Check from "pulsoicon-astro/icons/check"; --- ``` `getIconHandle` returns `undefined` until the icon's own script has run. ## Solid icons `solid` draws the filled version of an icon, in `color`. About 1,700 icons have a filled drawing; the others fill their closed shapes and cut their inner lines out of the fill. ## Finding icons Names follow lucide (`Calendar`, `Trash2`), every icon is also exported with an `Icon` suffix (`BellIcon`), and other icon sets' names work too (`Gear` is `Settings`, Tabler's `IconHome` is `Home`). Brand logos start with `Brand` (`BrandGithub`). Browse them all in the [repository README](https://github.com/CityPulso/PulsoIcon-Package#finding-icons). For icon pickers, `pulsoicon-astro/all` exports every icon component by its kebab-case name (all 9955 of them, so only where you need the full set), and `pulsoicon-astro/names` lists the names without loading any icon. To draw an icon from data you already have, use the generic `Icon` with an icon from `pulsoicon-core`; it renders the `` without the motion script: ```astro --- import { Icon } from "pulsoicon-astro"; import { Bell } from "pulsoicon-core/icons/bell"; --- ``` ## Styling Each icon renders ``, so CSS can target every icon (`.pulsoicon`) or one (`.pulsoicon-bell`). ## Other platforms The same icons, props and motion: [React, Vue, Svelte, Solid, Preact, Angular, Astro, Android (Jetpack Compose) and iOS (SwiftUI)](https://github.com/CityPulso/PulsoIcon-Package#packages). ## License ISC © CityPulso. Some icon shapes come from Lucide, Tabler Icons, Iconoir, Hugeicons and Phosphor; ship the [LICENSE](https://github.com/CityPulso/PulsoIcon-Package/blob/main/LICENSE) file with your app. What comes from where is listed in the [repository README](https://github.com/CityPulso/PulsoIcon-Package#license).