The Block decorator allows you to create stylized blocks.
You can create a Block using the static make()
method.
make(Closure|string|array $labelOrFields = '', array $fields = [])
make(Closure|string|array $labelOrFields = '', array $fields = [])
make(Closure|string|array $labelOrFields = '', array $fields = [])
make(Closure|string|array $labelOrFields = '', array $fields = [])
make(Closure|string|array $labelOrFields = '', array $fields = [])
use MoonShine\Decorations\Block;
use MoonShine\Fields\Text;
public function components(): array
{
return [
Block::make('Block title', [
Text::make('Name', 'first_name')
])
];
}
use MoonShine\Decorations\Block;
use MoonShine\Fields\Text;
//...
public function components(): array
{
return [
Block::make('Block title', [
Text::make('Name', 'first_name')
])
];
}
//...
use MoonShine\Decorations\Block;
use MoonShine\Fields\Text;
//...
public function components(): array
{
return [
Block::make('Block title', [
Text::make('Name', 'first_name')
])
];
}
//...
use MoonShine\Decorations\Block;
use MoonShine\Fields\Text;
//...
public function components(): array
{
return [
Block::make('Block title', [
Text::make('Name', 'first_name')
])
];
}
//...
use MoonShine\Decorations\Block;
use MoonShine\Fields\Text;
//...
public function components(): array
{
return [
Block::make('Block title', [
Text::make('Name', 'first_name')
])
];
}
//...

If the block does not need title, then the make()
method only has to pass an array.
use MoonShine\Decorations\Block;
use MoonShine\Fields\Text;
public function components(): array
{
return [
Block::make([
Text::make('Name', 'first_name')
])
];
}
use MoonShine\Decorations\Block;
use MoonShine\Fields\Text;
//...
public function components(): array
{
return [
Block::make([
Text::make('Name', 'first_name')
])
];
}
//...
use MoonShine\Decorations\Block;
use MoonShine\Fields\Text;
//...
public function components(): array
{
return [
Block::make([
Text::make('Name', 'first_name')
])
];
}
//...
use MoonShine\Decorations\Block;
use MoonShine\Fields\Text;
//...
public function components(): array
{
return [
Block::make([
Text::make('Name', 'first_name')
])
];
}
//...
use MoonShine\Decorations\Block;
use MoonShine\Fields\Text;
//...
public function components(): array
{
return [
Block::make([
Text::make('Name', 'first_name')
])
];
}
//...

The icon()
method allows you to add an icon.
use MoonShine\Decorations\Block;
public function components(): array
{
return [
Block::make('Block')
->icon('heroicons.outline.users')
];
}
use MoonShine\Decorations\Block;
//...
public function components(): array
{
return [
Block::make('Block')
->icon('heroicons.outline.users')
];
}
//...
use MoonShine\Decorations\Block;
//...
public function components(): array
{
return [
Block::make('Block')
->icon('heroicons.outline.users')
];
}
//...
use MoonShine\Decorations\Block;
//...
public function components(): array
{
return [
Block::make('Block')
->icon('heroicons.outline.users')
];
}
//...
use MoonShine\Decorations\Block;
//...
public function components(): array
{
return [
Block::make('Block')
->icon('heroicons.outline.users')
];
}
//...
For more detailed information, please refer to the section Icons.
