Blade Heroicons

repository·main·Indexed 20 days ago

https://github.com/driesvints/blade-heroicons

A Laravel package that integrates the Heroicons set into Blade views as reusable components or via the @svg directive. Supports outline, solid, mini, and micro icon prefixes, and allows publishing raw SVG icons as assets. Requires PHP 8.0+ and Laravel 9.0+.

Tokens
1.1K
Snippets
8
Records
10
Agent score
21%

What's inside blade-heroicons

  1. Correcting Chevron icon names

    main
    In older versions, some chevron icons were misspelled as cheveron. In current versions, these have been corrected to follow the official Heroicons naming convention (chevron). Ensure you update any references using the old spelling to avoid errors.
  2. Upgrade from Blade Icons to Blade Heroicons

    main

    If you are migrating from the original blade-icons package to blade-heroicons, the Blade component syntax remains unchanged. However, if you were using raw exported icons, you must re-publish them to ensure the new file structure is present.

    php artisan vendor:publish --tag=blade-heroicons --force
  3. Publish Raw SVG Icons as assets

    main

    If you need to use the icons as raw SVG files (e.g., in <img> tags) rather than Blade components, you can publish them to your vendor directory.

    php artisan vendor:publish --tag=blade-heroicons --force

    After publishing, you can use them in your views like this:

    <img src="{{ asset('vendor/blade-heroicons/o-arrow-left.svg') }}" width="10" height="10"/>
  4. Use Heroicons in Blade views

    main

    You can render Heroicons using self-closing Blade components. The component name follows the pattern x-heroicon-{prefix}-{name}.

    Icon Prefixes

    • o-: Outline icons
    • s-: Solid icons
    • m-: Mini icons
    • c-: Micro icons

    Adding Attributes

    You can pass CSS classes or inline styles directly to the component to control the icon's appearance.

    {{-- Basic usage --}}
    <x-heroicon-o-arrow-left />
    
    {{-- With classes --}}
    <x-heroicon-o-arrow-left class="w-6 h-6 text-gray-500" />
    
    {{-- With inline styles --}}
    <x-heroicon-o-arrow-left style="color: #555" />
    
    {{-- Solid icons --}}
    <x-heroicon-s-arrow-left />
    
    {{-- Mini icons --}}
    <x-heroicon-m-arrow-left />
    
    {{-- Micro icons --}}
    <x-heroicon-c-arrow-left />
  5. Upgrade from Blade Heroicons 1.x to 2.0

    main

    Upgrading to version 2.0 involves changes to system requirements and the underlying icon set:

    Minimum Requirements

    • PHP 8.0
    • Laravel 9.0

    Heroicons v2.0 Migration

    The package now uses Heroicons v2.0. Some icons have been removed or renamed. If you attempt to use an icon that no longer exists, Blade Icons will throw an exception. You should audit your icon usage and update names to match the new Heroicons v2.0 set.

  6. Reference raw Heroicons via SVG files

    main

    If you have published the raw icons, you can reference them directly using an <img> tag. The path follows the pattern vendor/blade-heroicons/{icon-name}.svg.

    <img src="{{ asset('vendor/blade-heroicons/o-adjustments.svg') }}" width="10" height="10"/>