Section
概述
你可以将多个 Entry 分到不同的分区(Section)中,每个都有一个标题及描述。为此,你可以使用 Section 组件:
use Filament\Infolists\Components\Section;
Section::make('Rate limiting')
->description('Prevent abuse by limiting the number of requests per period')
->schema([
// ...
])
![Section](https://github.com/filamentphp/filament/blob/3.x/docs-assets/screenshots/images/light/infolists/layout/section/simple.jpg?raw=true)
你也可以使用不带头部的分区,只需这样包裹子组件:
use Filament\Infolists\Components\Section;
Section::make()
->schema([
// ...
])
![Section without header](https://github.com/filamentphp/filament/blob/3.x/docs-assets/screenshots/images/light/infolists/layout/section/without-header.jpg?raw=true)
添加图标到 Section 头部
使用 icon()
方法,你可以将图标添加到 Section 头部:
use Filament\Infolists\Components\Section;
Section::make('Cart')
->description('The items you have selected for purchase')
->icon('heroicon-m-shopping-bag')
->schema([
// ...
])
![Section with icon](https://github.com/filamentphp/filament/blob/3.x/docs-assets/screenshots/images/light/infolists/layout/section/icons.jpg?raw=true)
将标题和描述放在边上
你可以使用 aside()
方法将左侧的标题和描述,与卡片内右侧的消息列表组件对齐。
use Filament\Infolists\Components\Section;
Section::make('Rate limiting')
->description('Prevent abuse by limiting the number of requests per period')
->aside()
->schema([
// ...
])
![Section with heading and description aside](https://github.com/filamentphp/filament/blob/3.x/docs-assets/screenshots/images/light/infolists/layout/section/aside.jpg?raw=true)
折叠 Section
Section 可设为可折叠 collapsible()
,以选择性隐藏长信息列表中的内容:
use Filament\Infolists\Components\Section;
Section::make('Cart')
->description('The items you have selected for purchase')
->schema([
// ...
])
->collapsible()
你可以将分区设为默认折叠,请使用 collapsed()
:
use Filament\Infolists\Components\Section;
Section::make('Cart')
->description('The items you have selected for purchase')
->schema([
// ...
])
->collapsed()
![Collapsed section](https://github.com/filamentphp/filament/blob/3.x/docs-assets/screenshots/images/light/infolists/layout/section/collapsed.jpg?raw=true)
压缩 Section 样式
当嵌套 Section 时,你可以使用更加紧凑的样式:
use Filament\Infolists\Components\Section;
Section::make('Rate limiting')
->description('Prevent abuse by limiting the number of requests per period')
->schema([
// ...
])
->compact()
![Compact section](https://github.com/filamentphp/filament/blob/3.x/docs-assets/screenshots/images/light/infolists/layout/section/compact.jpg?raw=true)
在分区中使用网格 columns
你也可以使用 columns()
方法,在分区内轻松创建 Grid:
use Filament\Infolists\Components\Section;
Section::make('Heading')
->schema([
// ...
])
->columns(2)