This page lists each blade-ui-kit/blade-icons call and its Rust equivalent, for code moving from PHP.
Calls
| PHP | Rust |
|---|---|
svg('heroicon-o-home') | icons.icon("heroicon-o-home")? |
svg('heroicon-o-home', 'size-6') | icons.svg("heroicon-o-home", "size-6", Attributes::new())? |
svg('heroicon-o-home', ['width' => 24]) | icons.svg_with("heroicon-o-home", Attributes::new().set("width", 24))? |
svg('heroicon-o-home', 'size-6', ['width' => 24]) | icons.svg("heroicon-o-home", "size-6", Attributes::new().set("width", 24))? |
['x-cloak'] (value without a key) | Attributes::new().flag("x-cloak") |
->toHtml() | .to_html() |
->strokeWidth(2) | .attr("stroke-width", 2)? |
->name(), ->contents(), ->attributes() | .name(), .contents(), .attributes() |
app(Factory::class)->all() | icons.sets() |
app(Factory::class)->add('name', [...]) | Icons::builder().set(IconSet::from_static(...)) |
Templates
| PHP Blade | oxblade |
|---|---|
{{ svg('heroicon-o-home', 'size-6') }} | the same |
@svg('heroicon-o-home', 'size-6') | the same |
<x-icon name="heroicon-o-home" class="size-6" /> | the same |
<x-heroicon-o-home class="size-6" /> | the same |
<x-heroicon-o-home defer /> | not supported (Error::Deferred) |
See Blade templates to register them.
Configuration
PHP config/blade-icons.php | Rust |
|---|---|
sets.heroicons.path | .set(icon_set!(oxblade_heroicons)) or IconSet::from_static |
sets.default.path = 'resources/svg' | a set named default (see Icon sets) |
sets.*.prefix | the second argument of IconSet::from_static / from_lookup |
sets.*.class, attributes, fallback | IconSet::class, attributes, fallback, or SetConfig |
class, attributes, fallback | IconsBuilder::class, attributes, fallback, or IconsConfig |
components.default | blade::Options::icon_component(Some("…")) |
components.disabled = true | Options::new().set_components(false) |
php artisan icons:cache, icons:clear | not needed; sets are compiled in |
The installation package for a set, such as blade-ui-kit/blade-heroicons, becomes a data crate such as
oxblade-heroicons from oxblade-icon-sets.
Behaviour to check
- A
titlefrom a plain string is escaped inside<title>; useTrusted(...)for PHP's exact output. to_html()doesn't add a second title when called twice.- Attribute names starting with
onare rejected. - Fallbacks must exist when the registry is built.
The README's Differences from PHP section lists each difference with its reason.