Out of the box, Aire comes with Tailwind-based templates that mostly mimic Bootstrap 4's aesthetic. It's easy to publish reusable Aire themes using Laravel's package auto-discovery.
Aire::setTheme($namespace = null, $prefix = null, $config = [])
Calling setTheme()
will tell Aire where to look for its associated
templates & apply any overrides to the configuration. By default, Aire loads views in
the format "aire::input"
.
Calling Aire::setTheme("mynamespace", "dark-variant")
would
cause Aire to look for the input view at "mynamespace::dark-variant.input"
which makes it easy to either publish a single theme, or multiple variants of the same theme
under one package.
If you're using package discovery,
you can add a call to Aire::setTheme()
in your service provider's boot()
method, and your theme will be automatically enabled when installed. This means that running…
composer require glhd/aire example/aire-sample-theme
…is all the end-user needs to do to use Aire and your theme!
A basic Aire theme would end up looking something like:
aire-sample-theme/
composer.json
src/
views/
form.blade.php
input.blade.php
...
composer.json
file
{
"name": "example/aire-sample-theme",
"description": "My custom Aire theme",
"require": {
"glhd/aire": "^1.1.0",
},
"autoload": {
"psr-4": {
"Example\\AireSampleTheme\\": "src/"
}
},
"extra": {
"laravel": {
"providers": [
"Example\\AireSampleTheme\\AireSampleThemeServiceProvider"
]
}
}
}
namespace Example\AireSampleTheme;
use Galahad\Aire\Aire;
use Illuminate\Support\ServiceProvider;
class AireSampleThemeServiceProvider extends ServiceProvider
{
public function boot()
{
$this->loadViewsFrom(dirname(__DIR__).'/views', 'aire-sample');
Aire::setTheme('aire-sample', null, array_replace_recursive(
// If you want to merge in the default Aire theme,
// you can load it via this static method
\Galahad\Aire\Aire::getDefaultThemeConfig(),
[
'default_classes' => [
'input' => 'my-custom-input-class',
],
]
));
}
}