unicon-rocks/unicon-laravel
Unicon Laravel integrates the Unicon icon library with Laravel, offering Blade components, helpers, and configuration to render and manage SVG icons from popular icon sets. It streamlines icon usage in views, letting you drop icons into templates without repetitive markup or setup.
Unicon gives Laravel a single Blade component for icons so you stop hand-copying SVGs into Blade files or wiring up three different icon packages. The value shows up the moment you have a navbar, a sidebar, and a few buttons that all need icons from different sets (Heroicons for UI chrome, Font Awesome for brands, Lucide for consistency) and you want one syntax for all of them.
Install and publish
composer require unicon-rocks/unicon-laravel
php artisan vendor:publish --tag=unicon-config # confirm tag in README
The config file is the first place to look. It typically holds the default icon set, default CSS classes/size, the local SVG path for your own icons, and any caching toggle. Read it top to bottom before writing any markup — most "why does this render wrong" questions are answered there.
First use case
Drop the component into a Blade view:
<x-unicon name="heroicon-o-home" class="w-5 h-5" />
(Exact component name and set prefixes are defined in the package's README/config — verify both before rollout. The mental model is <x-unicon name="{set}-{style}-{icon}" /> or a set-specific prefix per the config.)
A realistic first slice: replace the hard-coded SVGs in your layout's sidebar and topbar with <x-unicon> calls, keeping the existing Tailwind w-*/h-* classes. That gives you a 1:1 visual diff, and from then on swapping an icon is a one-word edit.
Treat the component as your icon vocabulary layer. The useful abstraction isn't "render an SVG" — it's "I reference icons by a stable name and the package resolves the SVG." Lean into that:
config/unicon.php so the 80% case is <x-unicon name="home" /> with no arguments, and only specify set=/class= when deviating.resources/views/components/icon.blade.php that wraps <x-unicon> with your house rules (default w-5 h-5, aria-hidden="true", a shared stroke width). Views then use <x-icon name="..." />, and you can change the underlying icon package or defaults in one file later.NavigationItem with an icon column, rendered as <x-unicon :name="$item->icon" />. Add a fallback (see Gotchas) so a bad name doesn't break a page.<x-unicon> into your Mailable views so transactional emails match the app.icon-left/icon-right props. It keeps the button component small and lets the caller control the icon.Suggested workflow for a team
README or a docs/icons.md.<x-icon> wrapper with accessibility defaults baked in.<svg in resources/views.home vs home-outline vs o-home). When an icon silently renders nothing, the name is almost always the culprit. Open the vendor directory or the README's icon index and search the exact string.app()->isLocal() and the icon is missing) or add a fallback icon in the wrapper component so production degrades gracefully.php artisan cache:clear / view:clear before you start debugging. Conversely, caching inline SVGs across a page with hundreds of icons is what keeps it fast; don't disable it in production.class= is merged onto the root <svg> and whether the package adds its own sizing classes that fight yours. If Tailwind's w-5 loses to an inline width attribute, you'll be chasing phantom sizing bugs.aria-hidden="true", and only add role="img" + <title>/aria-label for standalone icon buttons. Baking this into the wrapper (above) prevents the "every icon is announced twice" screen-reader complaint.style attributes. Inline SVGs sometimes carry style or <style> blocks that a strict Content-Security-Policy will block. If you have a CSP, test icons early — otherwise your whole icon layer breaks at deploy time, not in dev.<x-icon>, make sure it doesn't shadow a package or other component with the same name. Registering your wrapper under a distinct name (<x-ui.icon>) avoids surprises.composer.json, skim the package's src/ (it's small) before relying on undocumented behavior, and expect breaking changes on minor bumps. Treat the config file and the Blade component class as the source of truth over the README.resources/svg/), registering additional icon sets, per-set default classes, and a programmatic resolver/helper for cases where Blade isn't available (e.g. building strings in a service). If a needed hook doesn't exist, the component is thin enough to patch via your wrapper rather than forking.How can I help you explore Laravel packages today?