### Install Blade Font Awesome
Source: https://context7.com/owenvoke/blade-fontawesome/llms.txt
Install the package via Composer. Optionally, publish the configuration file or raw SVG assets.
```bash
composer require owenvoke/blade-fontawesome
```
```bash
php artisan vendor:publish --tag=blade-fontawesome-config
```
```bash
php artisan vendor:publish --tag=blade-fontawesome --force
```
--------------------------------
### Sync Font Awesome Pro Icons
Source: https://github.com/owenvoke/blade-fontawesome/blob/main/README.md
After installing Font Awesome Pro via npm, run this command to sync the pro icons into your project's resources.
```shell
php artisan blade-fontawesome:sync-icons --pro
```
--------------------------------
### Using Font Awesome Icon Components in Blade
Source: https://context7.com/owenvoke/blade-fontawesome/llms.txt
Demonstrates how to render free and pro Font Awesome icons using Blade components. Free sets are bundled, while pro sets require additional setup.
```blade
{{-- Brands --}}
{{-- Regular --}}
{{-- Solid --}}
{{-- PRO SETS (requires fontawesome-pro npm package + sync) --}}
{{-- Duotone --}}
{{-- Light --}}
{{-- Thin --}}
{{-- SHARP VARIANTS (pro) --}}
{{-- Note: colon in prefix becomes a Blade-safe separator --}}
{{-- Sharp Solid (prefix: fas:sharp) --}}
{{-- Sharp Light (prefix: fal:sharp) --}}
{{-- Sharp Thin (prefix: fat:sharp) --}}
{{-- Sharp Regular (prefix: far:sharp) --}}
{{-- Sharp Duotone (prefix: fad:sharp) --}}
{{-- CUSTOM KIT ICONS (pro, requires kit sync) --}}
{{-- Kit icon (prefix: fak) --}}
```
--------------------------------
### Install Blade Font Awesome via Composer
Source: https://github.com/owenvoke/blade-fontawesome/blob/main/README.md
Use this command to add the package to your Laravel project.
```shell
composer require owenvoke/blade-fontawesome
```
--------------------------------
### Sync Font Awesome Kit Icons
Source: https://github.com/owenvoke/blade-fontawesome/blob/main/README.md
After installing a Font Awesome Kit via npm, use this command to sync the kit icons into your project's resources, replacing 'KIT_CODE' with your actual kit code.
```shell
php artisan blade-fontawesome:sync-icons --kit=KIT_CODE
```
--------------------------------
### Publish Blade Font Awesome Configuration
Source: https://github.com/owenvoke/blade-fontawesome/blob/main/README.md
Run this command to publish the configuration file for customization.
```shell
php artisan vendor:publish --tag=blade-fontawesome-config
```
--------------------------------
### Cache Icons for Performance
Source: https://github.com/owenvoke/blade-fontawesome/blob/main/README.md
Run this Artisan command to cache icons, which can improve performance when using pro or kit-supplied icons.
```shell
php artisan icons:cache
```
--------------------------------
### Run Project Tests
Source: https://github.com/owenvoke/blade-fontawesome/blob/main/README.md
Execute the test suite for the Blade Font Awesome package using Composer.
```shell
composer test
```
--------------------------------
### Blade Font Awesome Configuration File
Source: https://context7.com/owenvoke/blade-fontawesome/llms.txt
The configuration file allows setting default classes, fallback icons, and HTML attributes for each icon set. Pro sets can also be disabled here.
```php
return [
// Free: Brands set
'brands' => [
'prefix' => 'fab',
'fallback' => '', // icon name to use when requested icon not found
'class' => 'icon', // default class applied to every icon in this set
'attributes' => [
'width' => 20,
'height' => 20,
],
],
// Free: Regular set
'regular' => [
'prefix' => 'far',
'fallback' => '',
'class' => '',
'attributes' => [],
],
// Free: Solid set
'solid' => [
'prefix' => 'fas',
'fallback' => '',
'class' => '',
'attributes' => [],
],
// Pro: Duotone – set to false to disable entirely
'duotone' => [
'prefix' => 'fad',
'fallback' => '',
'class' => '',
'attributes' => [],
],
// Pro: Light
'light' => [
'prefix' => 'fal',
'fallback' => '',
'class' => '',
'attributes' => [],
],
// Pro: Thin
'thin' => [
'prefix' => 'fat',
'fallback' => '',
'class' => '',
'attributes' => [],
],
// Pro: Sharp variants (set to false to disable)
'sharp-solid' => ['prefix' => 'fas:sharp', 'fallback' => '', 'class' => '', 'attributes' => []],
'sharp-light' => ['prefix' => 'fal:sharp', 'fallback' => '', 'class' => '', 'attributes' => []],
'sharp-regular' => ['prefix' => 'far:sharp', 'fallback' => '', 'class' => '', 'attributes' => []],
'sharp-thin' => ['prefix' => 'fat:sharp', 'fallback' => '', 'class' => '', 'attributes' => []],
'sharp-duotone-solid' => ['prefix' => 'fad:sharp', 'fallback' => '', 'class' => '', 'attributes' => []],
// Pro: Custom Kit icons
'custom-icons' => [
'prefix' => 'fak',
'fallback' => '',
'class' => '',
'attributes' => [],
],
// Disable a pro set entirely:
// 'sharp-regular' => false,
];
```
--------------------------------
### Publish Raw SVG Icons
Source: https://github.com/owenvoke/blade-fontawesome/blob/main/README.md
Use this command to publish all SVG icons to the public vendor directory for use with the `` tag.
```shell
php artisan vendor:publish --tag=blade-fontawesome --force
```
--------------------------------
### Syncing Font Awesome SVGs with Artisan
Source: https://context7.com/owenvoke/blade-fontawesome/llms.txt
The `sync-icons` Artisan command imports Font Awesome SVGs into your project, normalizing them for use. This is essential for pro and kit icons.
```bash
# Sync from @fortawesome/fontawesome-pro (default if both packages installed)
php artisan blade-fontawesome:sync-icons --pro
# Sync from @fortawesome/fontawesome-free
php artisan blade-fontawesome:sync-icons --free
# Sync from a Font Awesome Kit (replace KIT_CODE with your kit ID)
php artisan blade-fontawesome:sync-icons --kit=abc1234
# Specify a custom project root (useful in monorepos)
php artisan blade-fontawesome:sync-icons /path/to/project --pro
# Example output:
# Successfully updated Font Awesome SVGs
# - From: /var/www/node_modules/@fortawesome/fontawesome-pro/svgs
# - To: /var/www/resources/icons/blade-fontawesome
#
# Sets copied: brands, duotone, light, regular, sharp-regular, sharp-solid, solid, thin
```
```bash
# Install Font Awesome Pro
npm install --save @fortawesome/fontawesome-pro
# Install a Font Awesome Kit
npm install --save '@awesome.me/kit-abc1234@latest'
# Then run the sync
php artisan blade-fontawesome:sync-icons --pro
# or
php artisan blade-fontawesome:sync-icons --kit=abc1234
```
--------------------------------
### Caching Font Awesome Icons
Source: https://context7.com/owenvoke/blade-fontawesome/llms.txt
For production environments, it's recommended to cache icon sets using the Blade Icons caching mechanism to improve performance.
```bash
# Cache all registered icon sets
php artisan icons:cache
```
--------------------------------
### Clear Icon Cache
Source: https://context7.com/owenvoke/blade-fontawesome/llms.txt
Use this Artisan command to clear the cached Font Awesome icons.
```bash
php artisan icons:clear
```
--------------------------------
### Compile SVGs Action
Source: https://context7.com/owenvoke/blade-fontawesome/llms.txt
Internal action class to post-process SVG files. It adds `fill="currentColor"` and removes `height="1em"` for better CSS integration. This action normalizes SVGs in-place within a specified directory.
```php
use OwenVoke\BladeFontAwesome\Actions\CompileSvgsAction;
// Normalize a directory of SVGs in-place
$action = new CompileSvgsAction(
svgDirectory: '/path/to/source/svgs',
svgOutputDirectory: '/path/to/output/svgs' // can be the same directory
);
$action->execute();
// Before: