空状态
简介
表格的"空状态"在表格中没有行时渲染。

设置空状态标题
要自定义空状态的标题,请使用 emptyStateHeading() 方法:
use Filament\Tables\Table;
public function table(Table $table): Table
{
return $table
->emptyStateHeading('No posts yet');
}

设置空状态描述
要自定义空状态的描述,请使用 emptyStateDescription() 方法:
use Filament\Tables\Table;
public function table(Table $table): Table
{
return $table
->emptyStateDescription('Once you write your first post, it will appear here.');
}

设置空状态图标
要自定义空状态的图标,请使用 emptyStateIcon() 方法:
use Filament\Tables\Table;
public function table(Table $table): Table
{
return $table
->emptyStateIcon('heroicon-o-bookmark');
}
![]()
添加空状态操作
你可以向空状态添加操作以提示用户采取行动。将这些传递给 emptyStateActions() 方法:
use Filament\Actions\Action;
use Filament\Tables\Table;
public function table(Table $table): Table
{
return $table
->emptyStateActions([
Action::make('create')
->label('Create post')
->url(route('posts.create'))
->icon('heroicon-m-plus')
->button(),
]);
}

使用自定义空状态视图
你可以通过将其传递给 emptyState() 方法来使用完全自定义的空状态视图:
use Filament\Tables\Table;
public function table(Table $table): Table
{
return $table
->emptyState(view('tables.posts.empty-state'));
}