Docs
Creating blocks
Write a block: a PHP class, a Blade view and one line to register it.
A block is two files: a class that describes it (its fields, defaults and what the AI should know) and a Blade view that draws it. The same view renders on your website, in the visual editor and in previews. php artisan aurora:make-block Quote creates both, ready to fill in.
1. The class
namespace App\Blocks;
use Aurora\Blocks\Block;
use Aurora\Blocks\Editable;
use Filament\Forms\Components\TextInput;
class QuoteBlock extends Block
{
public static function type(): string
{
return 'quote';
}
public static function label(): string
{
return __('Quote');
}
public static function description(): string
{
return __('A short quote with who said it.');
}
public static function defaults(): array
{
return ['quote' => 'Simple things should be simple.', 'author' => 'Alan Kay'];
}
public static function editables(): array
{
return ['quote' => Editable::text()->multiline()];
}
public static function schema(): array
{
return [
TextInput::make('quote')->label(__('Quote')),
TextInput::make('author')->label(__('Who said it')),
];
}
}
2. The view
An anonymous component named after the block's type. Mark text editors can change on the canvas with @editable.
@props(['data' => []])
<figure class="rounded-2xl bg-zinc-50 p-8">
<blockquote class="text-2xl font-semibold" @editable('quote')>{{ $data['quote'] ?? '' }}</blockquote>
<figcaption class="mt-4 text-zinc-500">{{ $data['author'] ?? '' }}</figcaption>
</figure>
3. Its place in the palette
Blocks in app/Blocks are found on their own: there is nothing to register. To choose where they sit in the block palette, list them in your service provider; the rest follow.
use Aurora\Blocks\Blocks;
public function boot(): void
{
Blocks::register([
HeroBlock::class,
QuoteBlock::class,
]);
}
Blocks that hold blocks
A section, a grid or a row of buttons implements Aurora\Blocks\Contracts\Container and draws each slot with Blocks::slot('name'). Use Blocks::isEditing() in a view to skip animations or show placeholders while someone is editing.