Quick Start
You’ve installed the package. Now let’s get an icon on screen.
-
Download your first icon set
Swarm Icons ships with a CLI that pulls icon sets straight from npm: no Node.js needed. Grab Tabler Icons to start:
Terminal window vendor/bin/swarm-icons json:download tablerThis saves the full Tabler set as a JSON file in
resources/json/. You can download as many sets as you want: Material Design Icons, Heroicons, Lucide, and 200+ others are all available. -
Wire it up
Create a small bootstrap file (or add this to your existing one):
use Frostybee\SwarmIcons\SwarmIcons;use Frostybee\SwarmIcons\SwarmIconsConfig;$manager = SwarmIconsConfig::create()->discoverJsonSets()->cachePath(__DIR__ . '/cache/icons')->defaultPrefix('tabler')->build();SwarmIcons::setManager($manager);That’s the entire setup.
discoverJsonSets()finds every JSON file you’ve downloaded and makes it available.defaultPrefix('tabler')means you can write'home'instead of'tabler:home'for your most-used set. -
Render an icon
Now, anywhere in your app:
echo swarm_icon('home');That’s it. You’ll get a clean
<svg>tag witharia-hidden="true"applied automatically.Want to customize it? Chain fluent methods: each one returns a new immutable icon:
echo swarm_icon('home')->size(32)->class('text-blue-500');
Add more sets
Section titled “Add more sets”Need icons from different sets? Download them and reference by prefix:
vendor/bin/swarm-icons json:download mdi heroiconsecho swarm_icon('home'); // tabler (your default)echo swarm_icon('mdi:account'); // Material Designecho swarm_icon('heroicons:check-circle'); // HeroiconsEvery set gets its own prefix. No conflicts, no ambiguity.
Other ways to load icons
Section titled “Other ways to load icons”JSON collections are the recommended path, but you have options.
Your own SVG files: point at a directory and go:
->addDirectory('custom', __DIR__ . '/resources/icons')Live Iconify API: zero setup, fetches icons over HTTP on first use:
->addIconifySet('heroicons')Both at once: local files first, API as fallback:
->addHybridSet('icons', __DIR__ . '/my-icons')Each approach is covered in detail in the Providers section.
Next steps
Section titled “Next steps”Now that you have icons rendering, you might want to:
- Understand the architecture: Core Concepts explains providers, prefixes, and how attributes flow through the system.
- Fine-tune your setup: The Configuration Builder covers caching, default attributes, aliases, and more.
- Explore the CLI: Browse and search across 200+ icon sets to find exactly what you need.