Technical article
Design Blade components without over-engineering
Create Blade components only for repetition or clear semantic value, and keep unique page sections as ordinary markup.
- Laravel & PHP
- Design
- Blade
- components
- over-engineering

In this article
Create a Blade component for a repeated pattern with a clear contract: what data does it receive and what markup does it preserve? One-off layout does not need its own abstraction. Extract when shared meaning is clearer than the variation.
A card as a bounded pattern
Illustrative example: three knowledge lists show a title, short content, border and spacing. A card with one title prop and a slot avoids each list inventing its own spacing. The card below does not fetch data or decide which user may see the content.
@props(['title'])
<article {{ $attributes->class('rounded-xl border bg-white p-6 shadow-sm') }}>
<h2 class="text-xl font-bold">{{ $title }}</h2>
<div class="mt-3 text-slate-600">
{{ $slot }}
</div>
</article>Blade’s escaped {{ }} output uses htmlspecialchars; keep it for the title. Raw {!! !!} output requires a separate trusted-HTML contract. The attribute bag lets callers add an id or extra classes. Decide which attributes are public and which the component fixes internally.
When a variant deserves a separate component
Do not accumulate isInvoice, isProfile, compact and interactive when cards perform different jobs. An invoice-summary domain component can compose the simple card. If a component only moves one div without adding meaning, keep that markup with the page. This is a design judgement, not a fixed minimum-occurrence rule.
Check the rendered contract
- Render a title containing < and & and inspect escaping.
- Render with an extra class and id and inspect the final attributes.
- Check that h2 fits the heading hierarchy at every call site.
- For a field component, test label/for, unique id and error association in rendered markup.
The Blade fragment was reviewed against documentation but not rendered with Laravel. Check the rendered contract in your test application.
Last updated:


