Laravel
Beginner
1 min read
Blade Layouts and Components
Example
{{-- resources/views/layouts/app.blade.php --}}
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>@yield('title', 'My App')</title>
@stack('styles')
</head>
<body>
@include('partials.nav')
<main>@yield('content')</main>
@include('partials.footer')
@stack('scripts')
</body>
</html>
{{-- resources/views/components/alert.blade.php --}}
@props(['type' => 'info', 'dismissible' => false])
<div {{ $attributes->merge(['class' => 'alert alert-' . $type]) }}>
{{ $slot }}
@if($dismissible)
<button type="button" class="close">×</button>
@endif
</div>
{{-- Usage in a child view --}}
@extends('layouts.app')
@section('title', 'Dashboard')
@section('content')
<x-alert type="success" :dismissible="true">
Your profile has been updated.
</x-alert>
<h1>Welcome back!</h1>
@endsection
Related Resources
Laravel Reference
Complete tag & property list
Laravel How-To Guides
Step-by-step practical guides
Laravel Exercises
Practice what you've learned
More in Laravel