Skip to content

Layouts

Views in an application often share a lot of common elements, such as navigation, headers, footers, etc. To define the common interface, you can use layouts. Layouts are defined much like components, but are stored within resources/views/layouts/ instead of resources/views/components/:

resources/views/layouts/app.html.php
<!DOCTYPE html>
<html>
<head>
<title>Application Title</title>
</head>
<body>
<slot />
</body>
</html>

Within the layout, we define a slot-tag, which defines where the view content is meant to be rendered. To use the layout, you can reference it by prefixing x-layout:: to the layout path:

<x-layout::app>
<h1>Dashboard</h1>
</x-layout::app>

Passing attributes

Much like components, layouts also support passing attributes:

resources/views/layouts/app.html.php
<!DOCTYPE html>
<html>
<head>
<title>{{ $title ?? 'Application Title' }}</title>
</head>
<body>
<slot />
</body>
</html>
<x-layout::app title="Dashboard">
<h1>Dashboard</h1>
</x-layout::app>