Skip to content

Dashboard

The start page of a panel (/admin) is Anvil\Page\Dashboard, registered in pages() (the default). It shows:

  • a welcome line with the username,
  • the widgets of the panel, arranged by every user,
  • the resources the user may open, as tiles.
use Anvil\Widget\StatWidget;
public function widgets(): array
{
return [
StatWidget::make('Open tasks')
->value(fn () => model(TaskModel::class)->where('status', 'open')->countAllResults())
->icon('list-check')->color('warning')
->url($this->url('tasks'))
->permission('tasks.view'),
];
}
  • Values are computed only when the widget is shown.
  • Widgets with a permission are hidden from users without it.
  • Query through resources ($resource->query()) so that tenant and scopeQuery() apply.
  • Every user can show, hide, move and resize the widgets, separately for phones, tablets and desktops; the layout is stored per user.

All widget types – stat, grouped stats, chart, table, own widgets – and their options: Widgets.

The dashboard has no permission of its own (permission() returns null): every user of the panel may open it and sees what their permissions allow. It is always first in the navigation.

Replace it with a class of your own that extends Dashboard (to keep the widget board) or Page:

use Anvil\Page\Dashboard;
final class AdminDashboard extends Dashboard
{
public function subtitle(): ?string
{
return 'Good morning';
}
}
// in the panel
public function pages(): array { return [AdminDashboard::class, ...]; }

isDashboard() returning true makes a page the start page; there should be one per panel. Other pages with widgets use the same editor through WidgetBoard, see Arranged by every user.