🎉 Welcome to the new major version: v3. Upgrade now!

Powerful suite of Blade components for TALL Stack apps.

Layout

Layout component.

The TallStackUI layout component was introduced in version 2 for dashboard creation and has been enhanced in version 3 with features like a collapsible sidebar, collapsed branding, a sidebar footer slot, and item badges. While this component is simple, it is complete in every way. Due to the format of the TallStackUI documentation, there will be no code examples of the layout that makes it display.

Here is a complete example of using the layout component:

<body>
 
<x-layout>
<x-slot:header>
<x-layout.header>
<x-slot:right>
<x-dropdown text="Hello, {{ auth()->user()->name }}!">
<form method="POST" action="{{ route('logout') }}">
@csrf
<x-dropdown.items text="Logout" onclick="event.preventDefault(); this.closest('form').submit();" />
</form>
</x-dropdown>
</x-slot:right>
</x-layout.header>
</x-slot:header>
 
<x-slot:menu>
<x-side-bar>
<x-side-bar.item text="Home" icon="home" :route="route('dashboard')" />
<x-side-bar.item text="Settings" icon="cog" :route="route('settings')" />
</x-side-bar>
</x-slot:menu>
 
{{ $slot }}
</x-layout>
 
@livewireScripts
</body>

Before continuing, you may have noticed the following:

  • The layout component has multiple slots
  • The layout component has other components, such as layout.header
  • In this example, we are using other components from TallStackUI, such as dropdown
Layout Slots

This slot is used to position the component layout.header :

<x-slot:header>
<x-layout.header>
<!-- ... -->
</x-layout.header>
</x-slot:header>

This slot is used to position the comonent side-bar :

<x-slot:menu>
<x-side-bar>
<!-- ... -->
</x-side-bar>
</x-slot:menu>

Although it was not used in the example above, this slot is positioned above the menu slot and was created to receive any content added in this position. Internally it is applied like this:

<div x-data="{ tallStackUiMenuMobile : false }" x-on:tallstackui-menu-mobile.window="tallStackUiMenuMobile = $event.detail.status">
@if ($top)
{{ $top }}
@endif
@if ($menu)
{{ $menu }}
@endif
 
<!-- ... -->
</div>
Children Components

The layout.header component is used to group three specific slots that vary the positions of content in the top horizontal bar, called the header.

<x-layout.header>
<x-slot:left>
<!-- ... -->
</x-slot:left>
 
<x-slot:middle>
<!-- ... -->
</x-slot:middle>
 
<x-slot:right>
<!-- ... -->
</x-slot:right>
</x-layout.header>
  • left : adds content to the left of the horizontal bar
  • middle : adds content to the middle of the horizontal bar
  • right : adds content to the right of the horizontal bar

Additionally, you can control the display of a button that opens the side-bar on mobile devices. You will learn more about this as you continue reading the documentation below.

When using the collapsible attribute, you can provide a brand-collapsed slot to display a compact version of your branding when the sidebar is collapsed. This is useful for showing an icon instead of a full logo:

<x-side-bar collapsible>
<x-slot:brand>
<div class="flex justify-center">
<img src="/logo-full.svg" class="h-8" />
</div>
</x-slot:brand>
<x-slot:brand-collapsed>
<div class="flex justify-center">
<img src="/logo-icon.svg" class="h-6" />
</div>
</x-slot:brand-collapsed>
 
<!-- side-bar items goes here... -->
</x-side-bar>

By default, sidebar items use the route attribute which integrates with smart route matching and wire:navigate . If you need to link to an external URL or bypass route matching entirely, use the href attribute instead:

<!-- Using named route (supports smart matching + wire:navigate) -->
<x-side-bar.item text="Dashboard" icon="home" :route="route('dashboard')" />
 
<!-- Using raw href (bypasses route matching and wire:navigate) -->
<x-side-bar.item text="External Docs" icon="book-open" href="https://docs.example.com" />

The match attribute provides a flexible way to control the active state of a sidebar item using a route name pattern. This is useful when you want an item to appear active across multiple related routes:

<x-side-bar.item text="Orders"
icon="shopping-cart"
:route="route('orders.index')"
match="orders.*" />

Sidebar items support a badge slot to display notification counts or labels. You can customize the badge color using the badge-color attribute:

<x-side-bar.item text="Notifications" icon="bell" :route="route('notifications')">
<x-slot:badge>5</x-slot:badge>
</x-side-bar.item>
 
<!-- Custom badge color -->
<x-side-bar.item text="Messages" icon="envelope" badge-color="blue" :route="route('messages')">
<x-slot:badge>3</x-slot:badge>
</x-side-bar.item>

If for some reason you do not want to use the layout components - the main component and its child components, you can set the environment variable TALLSTACKUI_AVOID_LAYOUT_REGISTRATION to true to achieve this behavior without having to publish the configuration file and comment out the components - which would also be a valid measure, but less practical.

All the components mentioned above are available to be fully customized through one of the TallStackUI customization methods: soft customization or deep customization.

Code highlighting provided by Torchlight