--- title: Widgets --- ## Overview Filament allows you to display widgets inside pages, below the header and above the footer. You can use an existing [dashboard widget](../dashboard), or create one specifically for the resource. ## Creating a resource widget To get started building a resource widget: ```bash php artisan make:filament-widget CustomerOverview --resource=CustomerResource ``` This command will create two files - a widget class in the `app/Filament/Resources/CustomerResource/Widgets` directory, and a view in the `resources/views/filament/resources/customer-resource/widgets` directory. You must register the new widget in your resource's `getWidgets()` method: ```php public static function getWidgets(): array { return [ CustomerResource\Widgets\CustomerOverview::class, ]; } ``` If you'd like to learn how to build and customize widgets, check out the [Dashboard](../dashboard) documentation section. ## Displaying a widget on a resource page To display a widget on a resource page, use the `getHeaderWidgets()` or `getFooterWidgets()` methods for that page: ```php getPageTableQuery()` method: ```php use Filament\Widgets\StatsOverviewWidget\Stat; Stat::make('Total Products', $this->getPageTableQuery()->count()), ``` Alternatively, you can access a collection of the records on the current page using the `$this->getPageTableRecords()` method: ```php use Filament\Widgets\StatsOverviewWidget\Stat; Stat::make('Total Products', $this->getPageTableRecords()->count()), ``` ## Passing properties to widgets on resource pages When registering a widget on a resource page, you can use the `make()` method to pass an array of [Livewire properties](https://livewire.laravel.com/docs/properties) to it: ```php protected function getHeaderWidgets(): array { return [ CustomerResource\Widgets\CustomerOverview::make([ 'status' => 'active', ]), ]; } ``` This array of properties gets mapped to [public Livewire properties](https://livewire.laravel.com/docs/properties) on the widget class: ```php use Filament\Widgets\Widget; class CustomerOverview extends Widget { public string $status; // ... } ``` Now, you can access the `status` in the widget class using `$this->status`.