In this lesson, we will explore how to change the look of the page's main elements: the logo, colors, layout, and navigation.
Changing the App Name
Your application's default name at the top left, beside the logo, is "Laravel Starter Kit". You can change it in the logo component file.
resources/views/components/app-logo.blade.php:
BEFORE:
<span class="mb-0.5 truncate leading-none font-semibold">Laravel Starter Kit</span>
AFTER:
<span class="mb-0.5 truncate leading-none font-semibold">Livewire Tasks</span>
Changing the Name COLOR
With the same example, let's change the color with Tailwind, adding a text-blue-800
class.
resources/views/components/app-logo.blade.php
BEFORE:
<span class="mb-0.5 truncate leading-none font-semibold">Livewire Tasks</span>
AFTER:
<span class="mb-0.5 truncate leading-none font-semibold text-blue-800">Livewire Tasks</span>
Here's the visual result:
Notice: we're running npm run dev
in the background to re-compile CSS styles automatically after every change.
Changing the Logo Icon
The logo icon is SVG, so we can change it with any other SVG we want.
resources/views/components/app-logo-icon.blade.php
BEFORE:
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 40 42" {{ $attributes }}> <path fill="currentColor" fill-rule="evenodd" clip-rule="evenodd" d="M17.2 5.633 8.6.855 0 5.633v26.51l16.2 9 16.2-9v-8.442l7.6-4.223V9.856l-8.6-4.777-8.6 4.777V18.3l-5.6 3.111V5.633ZM38 18.301l-5.6 3.11v-6.157l5.6-3.11V18.3Zm-1.06-7.856-5.54 3.078-5.54-3.079 5.54-3.078 5.54 3.079ZM24.8 18.3v-6.157l5.6 3.111v6.158L24.8 18.3Zm-1 1.732 5.54 3.078-13.14 7.302-5.54-3.078 13.14-7.3v-.002Zm-16.2 7.89 7.6 4.222V38.3L2 30.966V7.92l5.6 3.111v16.892ZM8.6 9.3 3.06 6.222 8.6 3.143l5.54 3.08L8.6 9.3Zm21.8 15.51-13.2 7.334V38.3l13.2-7.334v-6.156ZM9.6 11.034l5.6-3.11v14.6l-5.6 3.11v-14.6Z" /></svg>
AFTER:
<svg viewBox="0 0 30 32" xmlns="http://www.w3.org/2000/svg" {{ $attributes }}> <path d="M7.015 25.238V0H0v32h12.303c7.387 0 12.223-2.902 14.854-7.028l-14.854.266H7.015Z" fill="#fff" /> <path d="M13.95 6.416h2.445c4.384 0 7.44 3.168 7.44 8.146 0 1.278-.212 2.423-.558 3.435h6.351c.24-1.092.372-2.237.372-3.435C30 6.336 24.128.027 16.422.027h-2.445l-.027 6.389Z" fill="#fff" /></svg>
Visual result:
Changing the Logo Color
There are two different component files: app-logo-icon.blade.php
and app-logo.blade.php
. We can change the Tailwind CSS color for the logo from text-white
to text-blue-100
and add a few CSS classes to the main div
.
resources/views/components/app-logo.blade.php
BEFORE:
<div class="flex aspect-square size-8 items-center justify-center rounded-md bg-accent-content text-accent-foreground"> <x-app-logo-icon class="size-5 fill-current text-white dark:text-black" /></div><div class="ml-1 grid flex-1 text-left text-sm"> <span class="mb-0.5 truncate leading-none font-semibold text-blue-800">Livewire Tasks</span></div>
AFTER:
<div class="bg-linear-to-r from-blue-500 to-blue-600 flex aspect-square size-8 items-center justify-center rounded-md text-accent-foreground"> <x-app-logo-icon class="size-5 fill-current text-white dark:text-black" /></div><div class="ml-1 grid flex-1 text-left text-sm"> <span class="mb-0.5 truncate leading-none font-semibold text-blue-800">Livewire Tasks</span></div>
Visual result:
The Tailwind structure we've used here is called Linear background gradient.
Changing Sidebar Active Color
Quite a few CSS styles are defined in the resources/css/app.css
file.
For example, let's change the styling of the active menu item.
resources/css/app.css:
// ... [data-current] { @apply bg-[oklch(0.846_0.076_269.861/0.19)] dark:bg-[oklch(0.269_0_0)];}
Visual result:
Notice: If you're not familiar with the oklch
color format, I suggest you read this article.
Changing from Sidebar to Topbar layout
Laravel starter kits allow us to easily change the navigation from the sidebar to the topbar. Two layouts are available, and you just need to change which one you're using.
resources/views/components/layouts/app.blade.php:
<x-layouts.app.sidebar :title="$title ?? null"> <x-layouts.app.header :title="$title ?? null"> <flux:main> {{ $slot }} </flux:main></x-layouts.app.sidebar> </x-layouts.app.header>
Visual result:
For the rest of this course, we will stay with the header layout and the navigation on top.
Changing TopBar Active Menu Item Color
The final change in this lesson is for the active menu item.
resources/css/app.css:
BEFORE:
[data-current] { @apply bg-[oklch(0.846_0.076_269.861/0.19)] dark:bg-[oklch(0.269_0_0)];}
AFTER:
[data-current] { @apply bg-[oklch(0.846_0.076_269.861/0.19)] after:bg-blue-600 dark:bg-[oklch(0.269_0_0)];}
And now we have a blue color for the active menu item:
These are just a few examples of customizations.
The main logic is this:
- You need to find the Blade component where the element is located
- Be familiar with Tailwind to customize the styling
If you're new to Tailwind, we have a separate course called Tailwind CSS for Laravel Developers.
In the next lesson, we will move beyond the default starter kit and start building our own Laravel + Livewire CRUD on top of it.
The repository for this starter kit project section is here on GitHub.
No comments yet…