# Widgets

we built a widget Facade service to make it easy to register a widget to the dashboard home page from any provider, so you can use it on your package or on your AppServiceProvider as well.

## Registering a widget

you can go to any service provider `boot()` method and register your widget like this:

```php
use TomatoPHP\TomatoAdmin\Facade\TomatoWidget;
use TomatoPHP\TomatoAdmin\Services\Contracts\Widget;

public function boot()
{
    TomatoWidget::register([
            Widget::make()
                ->title(__('Users'))
                ->icon('bx bxs-user')
                ->counter(User::count()),
            Widget::make()
                ->title(__('Roles'))
                ->icon('bx bx-lock')
                ->counter(Role::count())
        ]);
    }
}
```

and you will see the widget on the homepage of the dashboard directly.

### Widget Component

you can use Widget as a component like this

```html
 <x-tomato-admin-widget 
   :title="__('Total Users')" 
   icon="bx bxs-user" 
   :counter="\App\Models\Users::query()->count()"
 />
```


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.tomatophp.com/tomato-admin/widgets.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
