• Что бы вступить в ряды "Принятый кодер" Вам нужно:
    Написать 10 полезных сообщений или тем и Получить 10 симпатий.
    Для того кто не хочет терять время,может пожертвовать средства для поддержки сервеса, и вступить в ряды VIP на месяц, дополнительная информация в лс.

  • Пользаватели которые будут спамить, уходят в бан без предупреждения. Спам сообщения определяется администрацией и модератором.

  • Гость, Что бы Вы хотели увидеть на нашем Форуме? Изложить свои идеи и пожелания по улучшению форума Вы можете поделиться с нами здесь. ----> Перейдите сюда
  • Все пользователи не прошедшие проверку электронной почты будут заблокированы. Все вопросы с разблокировкой обращайтесь по адресу электронной почте : info@guardianelinks.com . Не пришло сообщение о проверке или о сбросе также сообщите нам.

Guide to using Filament Components in public-facing pages

Lomanu4 Оффлайн

Lomanu4

Команда форума
Администратор
Регистрация
1 Мар 2015
Сообщения
1,481
Баллы
155
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,
]);

//...
}
}
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>

@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],
};

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

Then, rebuild your CSS:


npm run build
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>


Пожалуйста Авторизируйтесь или Зарегистрируйтесь для просмотра скрытого текста.



Other components, such as

Пожалуйста Авторизируйтесь или Зарегистрируйтесь для просмотра скрытого текста.

, 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


Пожалуйста Авторизируйтесь или Зарегистрируйтесь для просмотра скрытого текста.



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!

?

Пожалуйста Авторизируйтесь или Зарегистрируйтесь для просмотра скрытого текста.

— it's free!


Пожалуйста Авторизируйтесь или Зарегистрируйтесь для просмотра скрытого текста.

 
Вверх Снизу