Some checks failed
CI / PHP 8.3 / mariadb:10.6 (pull_request) Successful in 1m14s
CI / PHP 8.4 / mariadb:10.6 (pull_request) Successful in 1m12s
CI / PHP 8.4 / mariadb:11.4 (pull_request) Successful in 1m7s
CI / PHP 8.3 / mariadb:11.4 (pull_request) Successful in 1m19s
CI / PHP 8.3 / mysql:8.0 (pull_request) Successful in 1m32s
CI / PHP 8.4 / mysql:8.0 (pull_request) Successful in 1m22s
CI / PHP 8.4 / mysql:8.4 (pull_request) Successful in 1m32s
CI / PHP 8.3 / mysql:8.4 (pull_request) Successful in 1m35s
CI / Build-Artefakte aktuell (pull_request) Failing after 1m7s
- Laravel 13 mit Filament 5 (Admin), Inertia 3 + Vue 3 + Vuetify 4 (Material 3) - Anmeldung über Fortify (Login, Passwort vergessen/ändern), keine Selbstregistrierung - Profil mit Profilbild (WebP in festen Größen), Personenseiten, Header mit Avatar-Menü - Material-3-Farbschema aus der Primärfarbe, hell/dunkel/System pro Person - Basis-Branding (Portalname, Logo, Primärfarbe) im Admin unter „Erscheinungsbild“ - Benutzerverwaltung im Admin, Zugang vorläufig über is_admin - vendor/ (ohne Dev-Pakete) und Frontend-Build mitversioniert, Dev-Pakete in vendor-dev/ - PHPUnit-Tests gegen MySQL/MariaDB, Forgejo-CI-Matrix, Docker-Entwicklungsumgebung - VERSION, CHANGELOG.md und CONTRIBUTING.md mit Release-Ablauf Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
329 lines
11 KiB
Markdown
329 lines
11 KiB
Markdown
---
|
|
title: Sections
|
|
---
|
|
import AutoScreenshot from "@components/AutoScreenshot.astro"
|
|
import UtilityInjection from "@components/UtilityInjection.astro"
|
|
|
|
## Introduction
|
|
|
|
You may want to separate your fields into sections, each with a heading and description. To do this, you can use a section component:
|
|
|
|
```php
|
|
use Filament\Schemas\Components\Section;
|
|
|
|
Section::make('Rate limiting')
|
|
->description('Prevent abuse by limiting the number of requests per period')
|
|
->schema([
|
|
// ...
|
|
])
|
|
```
|
|
|
|
<UtilityInjection set="schemaComponents" version="5.x">As well as allowing static values, the `make()` and `description()` methods also accept functions to dynamically calculate them. You can inject various utilities into the function as parameters.</UtilityInjection>
|
|
|
|
<AutoScreenshot name="schemas/layout/section/simple" alt="Section" version="5.x" />
|
|
|
|
You can also use a section without a header, which just wraps the components in a simple card:
|
|
|
|
```php
|
|
use Filament\Schemas\Components\Section;
|
|
|
|
Section::make()
|
|
->schema([
|
|
// ...
|
|
])
|
|
```
|
|
|
|
<AutoScreenshot name="schemas/layout/section/without-header" alt="Section without header" version="5.x" />
|
|
|
|
## Adding an icon to the section's header
|
|
|
|
You may add an [icon](../styling/icons) to the section's header using the `icon()` method:
|
|
|
|
```php
|
|
use Filament\Schemas\Components\Section;
|
|
use Filament\Support\Icons\Heroicon;
|
|
|
|
Section::make('Cart')
|
|
->description('The items you have selected for purchase')
|
|
->icon(Heroicon::ShoppingBag)
|
|
->schema([
|
|
// ...
|
|
])
|
|
```
|
|
|
|
<UtilityInjection set="schemaComponents" version="5.x">As well as allowing a static value, the `icon()` method also accepts a function to dynamically calculate it. You can inject various utilities into the function as parameters.</UtilityInjection>
|
|
|
|
<AutoScreenshot name="schemas/layout/section/icons" alt="Section with icon" version="5.x" />
|
|
|
|
## Positioning the heading and description aside
|
|
|
|
You may use the `aside()` to align heading & description on the left, and the components inside a card on the right:
|
|
|
|
```php
|
|
use Filament\Schemas\Components\Section;
|
|
|
|
Section::make('Rate limiting')
|
|
->description('Prevent abuse by limiting the number of requests per period')
|
|
->aside()
|
|
->schema([
|
|
// ...
|
|
])
|
|
```
|
|
|
|
<AutoScreenshot name="schemas/layout/section/aside" alt="Section with heading and description aside" version="5.x" />
|
|
|
|
Optionally, you may pass a boolean value to control if the section should be aside or not:
|
|
|
|
```php
|
|
use Filament\Schemas\Components\Section;
|
|
|
|
Section::make('Rate limiting')
|
|
->description('Prevent abuse by limiting the number of requests per period')
|
|
->aside(FeatureFlag::active())
|
|
->schema([
|
|
// ...
|
|
])
|
|
```
|
|
|
|
<UtilityInjection set="schemaComponents" version="5.x">As well as allowing a static value, the `aside()` method also accepts a function to dynamically calculate it. You can inject various utilities into the function as parameters.</UtilityInjection>
|
|
|
|
## Collapsing sections
|
|
|
|
Sections may be `collapsible()` to optionally hide long content:
|
|
|
|
```php
|
|
use Filament\Schemas\Components\Section;
|
|
|
|
Section::make('Cart')
|
|
->description('The items you have selected for purchase')
|
|
->schema([
|
|
// ...
|
|
])
|
|
->collapsible()
|
|
```
|
|
|
|
Your sections may be `collapsed()` by default:
|
|
|
|
```php
|
|
use Filament\Schemas\Components\Section;
|
|
|
|
Section::make('Cart')
|
|
->description('The items you have selected for purchase')
|
|
->schema([
|
|
// ...
|
|
])
|
|
->collapsed()
|
|
```
|
|
|
|
<AutoScreenshot name="schemas/layout/section/collapsed" alt="Collapsed section" version="5.x" />
|
|
|
|
Optionally, the `collapsible()` and `collapsed()` methods accept a boolean value to control if the section should be collapsible and collapsed or not:
|
|
|
|
```php
|
|
use Filament\Schemas\Components\Section;
|
|
|
|
Section::make('Cart')
|
|
->description('The items you have selected for purchase')
|
|
->schema([
|
|
// ...
|
|
])
|
|
->collapsible(FeatureFlag::active())
|
|
->collapsed(FeatureFlag::active())
|
|
```
|
|
|
|
<UtilityInjection set="schemaComponents" version="5.x">As well as allowing static values, the `collapsible()` and `collapsed()` methods also accept functions to dynamically calculate it. You can inject various utilities into the function as parameters.</UtilityInjection>
|
|
|
|
If a collapsed section contains components that are expensive to render, you can [defer the loading of its content](#deferring-the-loading-of-section-content) until the section is expanded.
|
|
|
|
### Persisting collapsed sections in the user's session
|
|
|
|
You can persist whether a section is collapsed in local storage using the `persistCollapsed()` method, so it will remain collapsed when the user refreshes the page:
|
|
|
|
```php
|
|
use Filament\Schemas\Components\Section;
|
|
|
|
Section::make('Cart')
|
|
->description('The items you have selected for purchase')
|
|
->schema([
|
|
// ...
|
|
])
|
|
->collapsible()
|
|
->persistCollapsed()
|
|
```
|
|
|
|
To persist the collapse state, the local storage needs a unique ID to store the state. This ID is generated based on the heading of the section. If your section does not have a heading, or if you have multiple sections with the same heading that you do not want to collapse together, you can manually specify the `id()` of that section to prevent an ID conflict:
|
|
|
|
```php
|
|
use Filament\Schemas\Components\Section;
|
|
|
|
Section::make('Cart')
|
|
->description('The items you have selected for purchase')
|
|
->schema([
|
|
// ...
|
|
])
|
|
->collapsible()
|
|
->persistCollapsed()
|
|
->id('order-cart')
|
|
```
|
|
|
|
Optionally, the `persistCollapsed()` method accepts a boolean value to control if the section should persist its collapsed state or not:
|
|
|
|
```php
|
|
use Filament\Schemas\Components\Section;
|
|
|
|
Section::make('Cart')
|
|
->description('The items you have selected for purchase')
|
|
->schema([
|
|
// ...
|
|
])
|
|
->collapsible()
|
|
->persistCollapsed(FeatureFlag::active())
|
|
```
|
|
|
|
<UtilityInjection set="schemaComponents" version="5.x">As well as allowing static values, the `persistCollapsed()` and `id()` methods also accept functions to dynamically calculate them. You can inject various utilities into the function as parameters.</UtilityInjection>
|
|
|
|
## Deferring the loading of section content
|
|
|
|
If the content of a section is expensive to render, you can pass a `Schema` object to `schema()` and use `deferLoading()`. This is particularly useful for a section that is [collapsed](#collapsing-sections) by default. The section and its header will render immediately, while its content will not be loaded until the section is expanded and the content enters the viewport:
|
|
|
|
```php
|
|
use Filament\Forms\Components\TextInput;
|
|
use Filament\Schemas\Components\Section;
|
|
use Filament\Schemas\Schema;
|
|
|
|
Section::make('Customer details')
|
|
->key('customerDetails')
|
|
->schema(
|
|
Schema::make()
|
|
->components([
|
|
TextInput::make('name'),
|
|
TextInput::make('email')
|
|
->email(),
|
|
])
|
|
->deferLoading(),
|
|
)
|
|
->collapsed()
|
|
```
|
|
|
|
Every deferred schema must have a unique key. In this example, the child schema inherits its key from the section. You can learn more in the [schema overview](overview#deferring-the-loading-of-a-child-schema).
|
|
|
|
## Compact section styling
|
|
|
|
When nesting sections, you can use a more compact styling:
|
|
|
|
```php
|
|
use Filament\Schemas\Components\Section;
|
|
|
|
Section::make('Rate limiting')
|
|
->description('Prevent abuse by limiting the number of requests per period')
|
|
->schema([
|
|
// ...
|
|
])
|
|
->compact()
|
|
```
|
|
|
|
<AutoScreenshot name="schemas/layout/section/compact" alt="Compact section" version="5.x" />
|
|
|
|
Optionally, the `compact()` method accepts a boolean value to control if the section should be compact or not:
|
|
|
|
```php
|
|
use Filament\Schemas\Components\Section;
|
|
|
|
Section::make('Rate limiting')
|
|
->description('Prevent abuse by limiting the number of requests per period')
|
|
->schema([
|
|
// ...
|
|
])
|
|
->compact(FeatureFlag::active())
|
|
```
|
|
|
|
<UtilityInjection set="schemaComponents" version="5.x">As well as allowing a static value, the `compact()` method also accepts a function to dynamically calculate it. You can inject various utilities into the function as parameters.</UtilityInjection>
|
|
|
|
## Secondary section styling
|
|
|
|
By default, sections have a contrasting background color, which makes them stand out against a gray background. Secondary styling gives the section a less contrasting background, so it is usually slightly darker. This is a better styling when the background color behind the section is the same color as the default section background color, for example when a section is nested inside another section. Secondary sections can be created using the `secondary()` method:
|
|
|
|
```php
|
|
use Filament\Schemas\Components\Section;
|
|
|
|
Section::make('Notes')
|
|
->schema([
|
|
// ...
|
|
])
|
|
->secondary()
|
|
->compact()
|
|
```
|
|
|
|
<AutoScreenshot name="schemas/layout/section/secondary" alt="Secondary section" version="5.x" />
|
|
|
|
Optionally, the `secondary()` method accepts a boolean value to control if the section should be secondary or not:
|
|
|
|
```php
|
|
use Filament\Schemas\Components\Section;
|
|
|
|
Section::make('Notes')
|
|
->schema([
|
|
// ...
|
|
])
|
|
->secondary(FeatureFlag::active())
|
|
```
|
|
|
|
## Inserting actions and other components in the header of a section
|
|
|
|
You may insert [actions](../actions) and any other schema component (usually [prime components](primes)) into the header of a section by passing an array of components to the `afterHeader()` method:
|
|
|
|
```php
|
|
use Filament\Schemas\Components\Section;
|
|
|
|
Section::make('Rate limiting')
|
|
->description('Prevent abuse by limiting the number of requests per period')
|
|
->afterHeader([
|
|
Action::make('test'),
|
|
])
|
|
->schema([
|
|
// ...
|
|
])
|
|
```
|
|
|
|
<UtilityInjection set="schemaComponents" version="5.x">As well as allowing a static value, the `afterHeader()` method also accepts a function to dynamically calculate it. You can inject various utilities into the function as parameters.</UtilityInjection>
|
|
|
|
<AutoScreenshot name="schemas/layout/section/header/actions" alt="Section with actions in the header" version="5.x" />
|
|
|
|
## Inserting actions and other components in the footer of a section
|
|
|
|
You may insert [actions](../actions) and any other schema component (usually [prime components](primes)) into the footer of a section by passing an array of components to the `footer()` method:
|
|
|
|
```php
|
|
use Filament\Schemas\Components\Section;
|
|
|
|
Section::make('Rate limiting')
|
|
->description('Prevent abuse by limiting the number of requests per period')
|
|
->schema([
|
|
// ...
|
|
])
|
|
->footer([
|
|
Action::make('test'),
|
|
])
|
|
```
|
|
|
|
<UtilityInjection set="schemaComponents" version="5.x">As well as allowing a static value, the `footer()` method also accepts a function to dynamically calculate it. You can inject various utilities into the function as parameters.</UtilityInjection>
|
|
|
|
<AutoScreenshot name="schemas/layout/section/footer/actions" alt="Section with actions in the footer" version="5.x" />
|
|
|
|
## Using grid columns within a section
|
|
|
|
You may use the `columns()` method to easily create a [grid](layouts#grid-system) within the section:
|
|
|
|
```php
|
|
use Filament\Schemas\Components\Section;
|
|
|
|
Section::make('Heading')
|
|
->schema([
|
|
// ...
|
|
])
|
|
->columns(2)
|
|
```
|
|
|
|
<AutoScreenshot name="schemas/layout/section/columns" alt="Section with grid columns" version="5.x" />
|
|
|
|
<UtilityInjection set="schemaComponents" version="5.x">As well as allowing a static value, the `columns()` method also accepts a function to dynamically calculate it. You can inject various utilities into the function as parameters.</UtilityInjection>
|