DEV Community

Cover image for Guide to using Filament Components in public-facing pages
yebor974 for Filament Mastery

Posted on • Originally published at filamentmastery.com on

2 1 1 1 1

Guide to using Filament Components in public-facing pages

This guide will show you how to include Filament components in your public-facing pages, step by step.

Step 1: Register your Filament colors globally

First, register your Filament colors in the AppServiceProvider inside the boot method:

use Filament\Support\Colors\Color;
use Filament\Support\Facades\FilamentColor;

class AppServiceProvider extends ServiceProvider
{
    /**
     * Bootstrap any application services.
     */
    public function boot(): void
    {
        FilamentColor::register([
            'danger' => Color::Red,
            'gray' => Color::Zinc,
            'info' => Color::Blue,
            'primary' => Color::Amber,
            'success' => Color::Green,
            'warning' => Color::Amber,
        ]);

        //...
    }
}

Enter fullscreen mode Exit fullscreen mode

Step 2: Set up the required Blade directives

To use Filament components on the front end, include the necessary styles and scripts in your Blade layout file (e.g., layouts/app.blade.php):

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>@yield('title')</title>

    <!-- Include Filament styles -->
    @filamentStyles

    @vite(['resources/css/app.css', 'resources/js/app.js'])
</head>
<body>
    @yield('content')

    <!-- Include Filament scripts -->
    @filamentScripts
</body>
</html>

Enter fullscreen mode Exit fullscreen mode

@filamentStyles and @filamentScripts are essential for loading Filament's assets.

Step 3: Configure Tailwind for Filament

Filament uses Tailwind CSS for styling, so you need to include Filament’s Tailwind configuration preset in your Tailwind setup.

Update your tailwind.config.js file as follows:

import preset from './vendor/filament/filament/tailwind.config.preset';

export default {
    content: [
        './resources/**/*.blade.php',
        './vendor/filament/**/*.blade.php',
    ],
    //...
    presets: [preset],
};

Enter fullscreen mode Exit fullscreen mode

This configuration ensures that Tailwind recognizes Filament’s styles and applies them correctly in your front office.

Then, rebuild your CSS:

npm run build

Enter fullscreen mode Exit fullscreen mode

Step 4: Use Filament components

Now you can use Filament components directly in your front office. For example, if you want to add a simple Filament button or section, you can do so like this:

<x-filament::button color="primary">
    Click Me
</x-filament::button>

<x-filament::section icon="heroicon-m-user"
                     icon-size="sm"
                     icon-color="primary"
                     class="mt-4">
    <x-slot name="heading">
        Section Heading
    </x-slot>

    <x-slot name="description">
        Section Description
    </x-slot>

    Content here
</x-filament::section>

Enter fullscreen mode Exit fullscreen mode

Filament Mastery Components on Public Pages

Other components, such as Blade components, can also be used with the same syntax.

Bonus: Add Notification Component

To use the notification component on your front-facing pages, follow these steps:

  1. Register the Livewire Notifications Component

  2. Send Notifications

Filament Mastery Public Notifications

Integrating Filament components into your application's front office can significantly enhance its functionality while maintaining a consistent design language with your admin panel. With just a few steps, you can leverage the power of Filament for both back-end and front-end development.

Enjoyed this article? Like it to let me know! You can share it too!

📬 Join the community on filamentmastery.com — it's free!

Tiugo image

Modular, Fast, and Built for Developers

CKEditor 5 gives you full control over your editing experience. A modular architecture means you get high performance, fewer re-renders and a setup that scales with your needs.

Start now

Top comments (0)

👋 Kindness is contagious

Delve into this thought-provoking piece, celebrated by the DEV Community. Coders from every walk are invited to share their insights and strengthen our collective intelligence.

A heartfelt “thank you” can transform someone’s day—leave yours in the comments!

On DEV, knowledge sharing paves our journey and forges strong connections. Found this helpful? A simple thanks to the author means so much.

Get Started