App shell with top nav

The other frame for an app: everything in one bar across the top (the brand, the pages with one group in a menu, then search, notifications, the theme and the account), an optional second row for a section's own pages, and the page under it. On a phone the pages fold into a drawer. Delivered as a layout component, components/layouts/app.blade.php, so a page reads <x-layouts.app title="…">, exactly as in the sidebar shell.

App shell with top nav, light and dark

App shell with top nav on a phone, light and dark

A block, not a component: copy the views below into your app. It assumes the base layout. It holds the command palette and the notification center, which are blocks of their own. It has the same name, and is handed the same data, as the sidebar shell: choose one, and the pages and the view composer stay as they are.

What it shows

  • The bar, a top nav: the brand, linking home; Home, Inbox with its count, My issues, Projects as a group that opens a menu of the projects and All projects, and Reports. The current page is marked (aria-current="page") from the route, and a group with the current page in it is drawn current too, as Projects is here.

  • Its actions: search (an icon button, with Ctrl+K or Cmd+K), the notification bell with its unread count, the theme switcher, and the user menu, compact, as an avatar.

  • A second row for a section's own pages, here a project's Issues, Board, Cycles and Settings as navigation tabs. A page fills it with a subnav slot; a page without one has no second row.

  • On a phone the pages move into a drawer opened by a menu button, as the top nav does below its collapseAt (md, 48rem of the bar's own width); the group opens in place there. The actions stay in the bar:

    The menu open on a phone, light and dark

  • Landmarks: the top nav's own "Skip to content" link (skipTo), its header and nav aria-label="Primary", and the page as main#main.

Built from

  • Top nav: the bar, its items, the Projects group and the drawer on a phone
  • Button: search
  • Theme switcher: light, dark or the system's
  • User menu: the account, as an avatar
  • Dropdown: the items in the user menu
  • Icon: the brand mark
  • Tabs: the project's pages in the second row
  • Page header, Panel and Badge: the sample page
  • Toast: the region on every page, and the status flashed to the page load

The markup

resources/views/components/layouts/app.blade.php

{{--
    The other frame: everything in one bar across the top, folding into a
    drawer on a phone, and an optional second row (subnav) for a section's
    own pages. Same name and same view composer as the sidebar shell, so a
    page does not change when the app swaps one for the other.
--}}
@props(['title'])

<x-layouts.base :title="$title">
    <x-ds::top-nav label="Primary" :sticky="true" skipTo="main" container="wide">
        <x-slot:brand>
            <a href="{{ route('home') }}" class="flex items-center gap-2 rounded-control text-body font-semibold text-fg focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-focus-ring">
                <x-ds::icon name="cube" variant="solid" size="5" class="text-accent" />
                Pebblework
            </a>
        </x-slot:brand>

        <x-ds::top-nav-item :href="route('home')" label="Home" :active="request()->routeIs('home')" />
        <x-ds::top-nav-item :href="route('inbox')" label="Inbox" :badge="$inboxCount ?: null" :active="request()->routeIs('inbox')" />
        <x-ds::top-nav-item :href="route('issues.mine')" label="My issues" :active="request()->routeIs('issues.mine')" />
        <x-ds::top-nav-item label="Projects">
            @foreach ($projects as $project)
                <x-ds::top-nav-item
                    :href="route('projects.show', $project['key'])"
                    :label="$project['name']"
                    :active="request()->is('projects/'.$project['key'], 'projects/'.$project['key'].'/*')"
                />
            @endforeach
            <x-ds::top-nav-item :href="route('projects.index')" label="All projects" :active="request()->routeIs('projects.index')" />
        </x-ds::top-nav-item>
        <x-ds::top-nav-item :href="route('reports.index')" label="Reports" :active="request()->routeIs('reports.*')" />

        <x-slot:actions>
            <x-ds::button
                variant="ghost"
                icon="magnifying-glass"
                :iconOnly="true"
                :href="route('search')"
                aria-label="Search"
                aria-keyshortcuts="Control+K Meta+K"
                x-data
                x-on:click.prevent="$dispatch('open-command-palette', { name: 'app' })"
            />
            <x-notification-bell :notifications="$latestNotifications" :unread="$unreadCount" />
            <x-ds::theme-switcher variant="button" />
            <x-ds::user-menu :name="$user->name" :email="$user->email" :compact="true" :signOutAction="route('logout')">
                <div role="group" aria-label="Account">
                    <x-ds::dropdown-item :href="route('settings.profile')" icon="user-circle">Profile</x-ds::dropdown-item>
                    <x-ds::dropdown-item :href="route('settings.workspace')" icon="cog-6-tooth">Workspace settings</x-ds::dropdown-item>
                </div>
                <div role="group" aria-label="Help">
                    <x-ds::dropdown-item :href="route('help')" icon="lifebuoy">Help and shortcuts</x-ds::dropdown-item>
                </div>
            </x-ds::user-menu>
        </x-slot:actions>
    </x-ds::top-nav>

    @isset($subnav)
        {{-- The tabs draw their own rule. --}}
        <div class="bg-surface">
            <div class="mx-auto max-w-7xl px-4">{{ $subnav }}</div>
        </div>
    @endisset

    {{-- A sticky page header stops under the bar: --ds-sticky-offset is its height and its rule. --}}
    <main id="main" tabindex="-1" class="mx-auto w-full max-w-7xl px-4 py-6 focus:outline-hidden lg:py-8 [--ds-sticky-offset:calc(3.5rem+1px)]">
        {{ $slot }}
    </main>

    <x-command-menu :recent="$recentIssues" />

    {{-- On every page, so a toast put in it is announced; the one flashed to this page load is put in a moment after Alpine starts. --}}
    <x-ds::toast-region label="Messages" :flash="session('status')" />
</x-layouts.base>

resources/views/projects/show.blade.php

{{--
    The sample page: one project, with its own pages in the second row.
    The controller passes $project and $issues.
--}}
<x-layouts.app :title="$project['name']">
    <x-slot:subnav>
        <x-ds::tabs :label="$project['name']" :navigation="true">
            <x-ds::tab :href="route('projects.show', $project['key'])" :active="true" :count="$project['open']">Issues</x-ds::tab>
            <x-ds::tab :href="route('projects.board', $project['key'])">Board</x-ds::tab>
            <x-ds::tab :href="route('projects.cycles', $project['key'])">Cycles</x-ds::tab>
            <x-ds::tab :href="route('projects.settings', $project['key'])">Settings</x-ds::tab>
        </x-ds::tabs>
    </x-slot:subnav>

    <div class="flex flex-col gap-6">
        <x-ds::page-header :title="$project['name']" :description="$project['description']">
            <x-slot:actions>
                <x-ds::button icon="plus" :href="route('issues.create', ['project' => $project['key']])">New issue</x-ds::button>
            </x-slot:actions>
        </x-ds::page-header>

        <x-ds::panel title="Open issues" :action="'All '.$project['open']" :actionHref="route('projects.show', $project['key'])">
            @foreach ($issues as $issue)
                <x-ds::panel-row :href="route('issues.show', $issue['key'])">
                    <span class="flex min-w-0 items-center gap-3">
                        <span class="w-16 shrink-0 text-meta tabular-nums text-fg-muted">{{ $issue['key'] }}</span>
                        <span class="min-w-0 flex-1 truncate text-fg">{{ $issue['title'] }}</span>
                        <x-ds::badge :tone="$issue['tone']">{{ $issue['status'] }}</x-ds::badge>
                    </span>
                </x-ds::panel-row>
            @endforeach
        </x-ds::panel>
    </div>
</x-layouts.app>

Wire it up

The wiring is the sidebar shell's: the same routes (less the sidebar's teams.create and current-team.update, which this shell does not use), and the same view composer on components.layouts.app. This shell reads user, projects, inboxCount, unreadCount, latestNotifications and recentIssues from it, and ignores teams. There is no collapse to remember, so no cookie.

A page with a second row

<x-layouts.app :title="$project->name">
    <x-slot:subnav>
        <x-ds::tabs :label="$project->name" :navigation="true">
            <x-ds::tab :href="route('projects.show', $project)" :active="request()->routeIs('projects.show')">Issues</x-ds::tab>
            <x-ds::tab :href="route('projects.board', $project)" :active="request()->routeIs('projects.board')">Board</x-ds::tab>
        </x-ds::tabs>
    </x-slot:subnav>

    <x-ds::page-header :title="$project->name" />
    …
</x-layouts.app>

Navigation tabs are links, each a page of its own, so the row needs no script and the current one is in the URL. Name the tabs' nav after the section (label), so it is not a second "Primary".

Which shell

The top nav suits an app with a handful of places, used in short visits; the sidebar suits one with many, used all day, where a workspace switcher and nested pages earn the column. Moving between them is one file: both are components/layouts/app.blade.php.

Phone, keyboard, no script

  • Phone: the top nav folds by its own width, not the window's, so the bar folds whenever its contents would not fit. The second row's tabs scroll sideways if they run out of room.
  • Keyboard: the skip link is the first Tab stop. The Projects group is a disclosure: Enter or Space opens it and Escape closes it. Ctrl+K (Cmd+K on a Mac) opens the palette.
  • No script: the top nav does not fold: its links wrap, and the group is a native details that opens without a script. The search button is a link to the search page and the bell a link to the notifications page. The theme switcher and the user menu need Alpine.

From the package repo: edit this page on GitHub.

Was this page helpful?