Blade Icons

Render SVG icons as native Blade components or directives in any Laravel app

Library
Composer
v1.10.1
2,480stars
MIT License

Repository Health

Pre-computed score based on development activity, maintenance, community, maturity, and trend momentum.How we score it →
66/100Good
Development Activity48
Maintenance48
Community68
Maturity60
Momentum40

Technical Analysis

AI-assessed by reading the actual repository — architecture, code quality, innovation, and documentation.How we score it →
81/100Excellent
Architecture80
Code Quality82
Innovation78
Learning Curve85

Blade Icons is a Laravel package that turns raw SVG files into first-class Blade components (<x-icon-camera />) or an @svg() directive, so icons can be dropped into views the same way any other Blade component is used. It registers icon sets by prefix and path, caches a manifest for fast lookups in production, and serves as the foundation for dozens of community-maintained icon packs (Heroicons, Font Awesome, Bootstrap Icons, and many more) that plug into the same API.

What You Get

  • Blade component (<x-icon-camera class="w-6 h-6" />) and @svg('camera', 'w-6 h-6') directive for rendering any registered icon
  • A Factory API for registering custom icon sets with prefixes, paths, and per-set default classes/attributes
  • An icons:cache Artisan command that pre-builds a manifest so icon discovery is a single file read in production instead of a filesystem scan
  • Support for icons served from Laravel filesystem disks (local or remote), not just the local disk
  • A stable base API that dozens of third-party icon-set packages (Heroicons, Font Awesome, Bootstrap Icons, Material Design Icons, and more) build on top of

Common Use Cases

  • Rendering a consistent icon system across a Laravel app’s Blade views without hand-writing SVG markup in templates
  • Installing a community icon-set package (e.g. Blade Heroicons) and using its icons immediately through the same component/directive API
  • Registering an app’s own custom SVG icon set alongside third-party packs, each under its own prefix
  • Precompiling the icon manifest as part of a deploy pipeline to avoid filesystem scans on every request

Under The Hood

ArchitectureBladeIconsServiceProvider wires up three collaborators at boot: a Factory (in src/Factory.php) that holds registered icon sets keyed by a unique prefix, resolving each set’s paths and optional filesystem disk; an IconsManifest that either scans the filesystem/disk directly or reads a precompiled JSON manifest for fast lookups; and two Blade integration points, the Icon and Svg components (src/Components/) plus the @svg() directive and svg() global helper (src/helpers.php), all of which resolve through the same Factory::svg() call so component, directive, and helper usage stay consistent. The icons:cache/icons:clear Artisan commands (src/Console/) are thin wrappers that call IconsManifest::write()/clear() to move icon discovery from request-time to deploy-time. Tech Stack — pure PHP 7.4/8.x targeting Laravel’s Illuminate contracts (illuminate/contracts, illuminate/filesystem, illuminate/support, illuminate/view) as a ^8.0 through ^13.0 compatible package, with symfony/finder used for local filesystem scanning and symfony/console pulled in transitively via the Artisan command layer; test tooling is orchestra/testbench (a Laravel-app harness for package testing) plus mockery and phpunit. Code Quality — the src/ tree is 13 files and stays flat and single-purpose per class (Factory, IconsManifest, Svg, Icon, two console commands, a small Generation/IconGenerator), every public class is final and strictly typed (declare(strict_types=1) throughout), and the tests/ directory mirrors this with 11 focused PHPUnit test files (FactoryTest, IconsManifestTest, ComponentsTest, CachingTest, DirectiveTest, FilesystemDiskTest, etc.) plus a TestCase built on Testbench, giving real Laravel-container-level coverage rather than isolated unit stubs. API Design — the public surface is deliberately small: a Blade component tag, an @svg() directive, and a svg() helper all converge on one Factory::svg() call, so there is exactly one mental model regardless of which syntax a template uses; registering a new icon set is a single Factory::add($name, ['paths' => ..., 'prefix' => ...]) call, and the README documents the full configuration surface (config/blade-icons.php) plus a large table of first- and third-party icon packages that extend the same API, keeping the learning curve low for both consumers and icon-pack authors.

Join founders buildingwith open source

Opinionated takes, migration guides, cost-saving tips, and insights from the open source ecosystem.

Subscribe on Substack
Join 750+ subscribers

Search