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!

Feature flag article image

Create a feature flag in your IDE in 5 minutes with LaunchDarkly’s MCP server ⏰

How to create, evaluate, and modify flags from within your IDE or AI client using natural language with LaunchDarkly's new MCP server. Follow along with this tutorial for step by step instructions.

Read full post

Top comments (0)

MongoDB Atlas runs apps anywhere. Try it now.

MongoDB Atlas runs apps anywhere. Try it now.

MongoDB Atlas lets you build and run modern apps anywhere—across AWS, Azure, and Google Cloud. With availability in 115+ regions, deploy near users, meet compliance, and scale confidently worldwide.

Start Free

👋 Kindness is contagious

Dive into this insightful article, celebrated by the caring DEV Community. Programmers from all walks of life are invited to share and expand our collective wisdom.

A simple thank-you can make someone’s day—drop your kudos in the comments!

On DEV, spreading knowledge paves the way and strengthens our community ties. If this piece helped you, a brief note of appreciation to the author truly counts.

Let’s Go!