php artisan aura:add code-block
Copies the component source into resources/views/components/aura/. Run php artisan aura:init first if you haven't already. See the CLI guide for all options.
composer require bluestarsystem/aura-ui
php artisan aura:install
Full installation instructions in the Installation guide.
Overview
<x-aura::code-block> presents a complete snippet. Its inline counterpart is
code, for a fragment inside running text.
The slot is taken literally, so the snippet can stay aligned with the Blade around it — the shared indentation is removed before it is shown or copied.
Basic Usage
bash
composer require bluestarsystem/aura-ui
<x-aura::code-block language="bash">composer require bluestarsystem/aura-ui</x-aura::code-block><x-aura::code-block language="bash">composer require bluestarsystem/aura-ui</x-aura::code-block>
With a filename
app/Http/Controllers/OrderController.php
php
public function store(StoreOrderRequest $request): RedirectResponse
{
$order = Order::create($request->validated());
return to_route('orders.show', $order);
}
<x-aura::code-block language="php" filename="app/Http/Controllers/OrderController.php">
public function store(StoreOrderRequest $request): RedirectResponse
{
$order = Order::create($request->validated());
return to_route('orders.show', $order);
}
</x-aura::code-block>Line numbers
routes/web.php
php
Route::get('/orders', [OrderController::class, 'index']); Route::post('/orders', [OrderController::class, 'store']);
<x-aura::code-block language="php" filename="routes/web.php" lines>
Route::get('/orders', [OrderController::class, 'index']);
Route::post('/orders', [OrderController::class, 'store']);
</x-aura::code-block>Props
| Prop | Type | Default | Description |
|---|---|---|---|
language |
string|null |
null |
Shown as a badge and set as language-* on the <code>, which is what a highlighter looks for. |
filename |
string|null |
null |
Displayed in the header. |
copyable |
bool |
true |
Shows the copy button. With no language, filename or copy button, no header is drawn at all. |
lines |
bool |
false |
Numbers each line. The numbers are aria-hidden, so they are not read out or copied. |
Accessibility
- The copy button has a visible label, or an
aria-labelwhen it is icon-only. - Copying updates a polite live region. A tick that only changes colour tells a sighted user it worked and tells a screen-reader user nothing.
- Where the clipboard API is unavailable — any
http://origin, and older browsers — it falls back to a hidden textarea rather than failing silently.