# Laravel (oxblade-icons)

> The laravel feature adds a service provider that builds the icon registry from application configuration, puts it in the container and registers the Blade…

- Package: oxblade-icons (Rust, alpha), crates: `oxblade-icons`
- Maintenance: active; Latest release: 0.1.0 (2026-12-05); MSRV: Rust 1.99 or later; Licence: MIT
- Links: [Repository](https://github.com/bowerbird-si/oxblade-icons), [crates.io](https://crates.io/crates/oxblade-icons/0.1.0), [docs.rs](https://docs.rs/oxblade-icons/0.1.0), [Changelog](https://oss.bowerbird.si/oxblade-icons/docs/changelog/), [Contributing](https://github.com/bowerbird-si/oxblade-icons/blob/c7e0252d5f06a12c2c4687fa63a4aa97d51b0e4c/CONTRIBUTING.md), [Security policy](https://github.com/bowerbird-si/oxblade-icons/blob/c7e0252d5f06a12c2c4687fa63a4aa97d51b0e4c/SECURITY.md)
- Based on: [blade-ui-kit/blade-icons](https://github.com/driesvints/blade-icons): The PHP renderer and template behavior this package ports.
- PHP parity: core (4 covered, 4 diverged, 3 planned of 11 abilities; 14 fixtures; follows blade-ui-kit/blade-icons 1.11.0; verified 2026-12-05)
- HTML version: https://oss.bowerbird.si/oxblade-icons/docs/laravel/
- Source: https://github.com/bowerbird-si/oxblade-icons/blob/c7e0252d5f06a12c2c4687fa63a4aa97d51b0e4c/docs/laravel.md

The `laravel` feature adds a service provider that builds the icon registry from application configuration, puts it in the container and registers the Blade extensions.

## Install

```toml
[dependencies]
oxblade-icons = { version = "0.1", features = ["laravel"] }
oxblade-heroicons = { git = "https://github.com/bowerbird-si/oxblade-icon-sets" }
```

The feature is tested with laravel-rust 0.2 and oxblade-laravel 0.2.

## Register the provider

Add `IconsServiceProvider` next to oxblade-laravel's `BladeServiceProvider`, with the sets you want:

```rust
use laravel::Application;
use oxblade_icons::{icon_set, laravel::IconsServiceProvider};
use oxblade_laravel::{BladeEngine, BladeServiceProvider};

let app = Application::configure()
    .with_providers(|providers| {
        providers.add(BladeServiceProvider::new(|_| BladeEngine::new()));
        providers.add(IconsServiceProvider::new().set(icon_set!(oxblade_heroicons)));
    })
    .create();
```

Views can then use `svg()`, `@svg`, `<x-icon>` and `<x-heroicon-o-home />` (see
[Blade templates](https://oss.bowerbird.si/oxblade-icons/docs/blade/)). No engine code is needed in the application. The registry is also in the
container as `Icons`:

```rust
let icons = app.resolve::<oxblade_icons::Icons>().await;
```

## Configure

`IconsConfig` holds the settings from Blade Icons' `config/blade-icons.php`. Set it in the application's
configuration:

```rust
use oxblade_icons::{Attributes, laravel::{IconsConfig, SetConfig}};

let app = Application::configure()
    .with_config(|config, _| {
        config.set(IconsConfig {
            class: "icon".into(),
            attributes: Attributes::new().set("focusable", "false"),
            fallback: Some("heroicon-o-question-mark-circle".into()),
            sets: [("heroicons".into(), SetConfig {
                class: Some("size-6".into()),
                ..SetConfig::default()
            })]
            .into(),
            ..IconsConfig::default()
        });
    })
    // .with_providers(…) as above
    .create();
```

| Field | Blade Icons key | Meaning |
| --- | --- | --- |
| `class` | `class` | Class for every icon |
| `attributes` | `attributes` | Attributes for every icon |
| `fallback` | `fallback` | Full icon name to show when one is missing |
| `sets` | `sets.*.class`, `attributes`, `fallback` | Overrides by set name; an empty `fallback` turns the set's fallback off |
| `components` | `components` | `blade::Options`: which components to install |

Without an `IconsConfig`, the provider reads `ICONS_CLASS` and `ICONS_FALLBACK` from the environment.

The configuration is checked when the application boots. A duplicate set or a fallback that doesn't exist
makes `boot()` return the error, instead of failing on the first page.

## Your own icons

To ship a folder of SVGs with the application, embed it with `laravel::embed!` and register it with
`oxblade_icons::laravel::embedded_set(name, prefix, folder)`. The files are trusted markup; see
[Icon sets](https://oss.bowerbird.si/oxblade-icons/docs/icon-sets/#your-own-svgs).

## Commands

- `icons:list` lists the names in registered static sets.
- `icons:check lucide-map-pin heroicon-o-home` checks exact names, even when a fallback is configured.
- `icons:licenses` prints the notices for the sets the app registered.

## Not included

Blade Icons' `icons:cache` and `icons:clear` commands have no equivalent: sets are compiled into the
binary, so there is nothing to cache.
