Row Links
Introduction
Row Links and actions can be used to provide additional functionality to the rows in a table. They can be used to navigate to a different page or perform an action. Before defining Row Links and actions, it is necessary to include the ActionColumn
in the Table's column array. The ActionColumn
is a special column that is used to define Row Links and actions. Without the ActionColumn
, Row Links and actions will not be displayed.
use InertiaUI\Table\Columns;
class Users extends Table
{
public function columns(): array
{
return [
Columns\TextColumn::make('email'),
Columns\ActionColumn::new(),
];
}
}
Row Links
Row Links are used to navigate to a different page when. To define a row link, pass the label as the first argument and a callback as the second argument. The callback should return the URL to navigate to when the row link is clicked.
use App\Models\User;
use InertiaUI\Table\Action;
class Users extends Table
{
public function actions(): array
{
return [
Action::make('Edit', fn (User $user) => route('users.edit', $user)),
];
}
}
Display links as buttons
By default, Row Links are displayed as text links. To display Row Links as buttons, you can use the asButton()
method.
Action::make('Edit', fn (User $user) => route('users.edit', $user))->asButton();
To display a row link as a primary or danger button, you can use the asPrimaryButton()
or asDangerButton()
method.
Action::make('Edit', fn (User $user) => route('users.edit', $user))->asPrimaryButton();
Action::make('Suspend', fn (User $user) => route('users.suspend', $user))->asDangerButton();
Alternatively, you can use the style
argument to specify the button style with the ActionStyle enum.
use InertiaUI\Table\ActionStyle;
Action::make(
label: 'Edit',
url: fn (User $user) => route('users.edit', $user),
style: ActionStyle::PrimaryButton
);