PHP code example of jacksleight / blade-tailor
1. Go to this page and download the library: Download jacksleight/blade-tailor library . Choose the download type require .
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
jacksleight / blade-tailor example snippets
use JackSleight\BladeTailor\Tailor;
Tailor::component('flux::button')
->props([
'variant' => 'primary', // Customise prop defaults
'huge' => false, // Add new props
])
->classes(fn ($variant, $huge) => [
'border-4 rounded-full -rotate-2 !shadow-drop-1g',
'scale-150' => $huge,
'[&>[data-flux-icon]]:: text-orange-500 size-10 -mx-2 mb-0.5 self-end',
match ($variant) {
'primary' => 'border-blue-300',
'danger' => 'border-red-800',
default => '',
},
]),
->attributes([ // Add new attributes
'data-thing' => 'foo',
]);
// Target multiple components
Tailor::component(['flux::button', 'core::*'])
->replace([ // Replace default classes
'text-sm' => 'text-base',
])
->remove([ // Remove default classes
'rounded',
])
->reset(true); // Remove all default classes
Tailor::component('core::card')
->root( // Customise root and slot elements
classes: 'rounded-2xl',
attributes: ['data-thing' => 'bar'],
)
->slot('image',
classes: 'rounded',
)
->slot('text',
classes: 'p-4',
);
js
content: [
// ...
"./resources/tailor.php",
],
blade
@tailor([
'type' => 'info',
'message',
])
<div {{ $attributes->class('text-blue-500') }}>
{{ $message }}
</div>