---
title: "Adding button to Widget"
manual: "Dashboard"
version: "main"
permalink: "https://docs.typo3.org/permalink/typo3/cms-dashboard:adding-buttons@main"
source: "Developer/AddingButtons.rst"
rendered: "2026-09-30T05:15:21+00:00"
---

# Adding button to Widget {#adding-buttons}

In order to add a button to a widget, a new dependency to an `ButtonProviderInterface` can be added.

## Template {#adding-buttons-template}

The output itself is done inside of the Fluid template, for example `Resources/Private/Templates/Widget/RssWidget.html`:

```html
<f:if condition="{button}">
   <a href="{button.link}" target="{button.target}" class="widget-cta">
      {f:translate(id: button.title, default: button.title)}
   </a>
</f:if>
```

## Configuration {#adding-buttons-configuration}

The configuration is done through an configured Instance of the dependency, for example `Services.yaml`:

```yaml
services:
  # …

  dashboard.buttons.t3news:
    class: 'TYPO3\CMS\Dashboard\Widgets\Provider\ButtonProvider'
    arguments:
      $title: 'LLL:EXT:dashboard/Resources/Private/Language/locallang.xlf:widgets.t3news.moreItems'
      $link: 'https://news.typo3.com'
      $target: '_blank'

  dashboard.widget.t3news:
    class: 'TYPO3\CMS\Dashboard\Widgets\RssWidget'
    arguments:
      # …
      $buttonProvider: '@dashboard.buttons.t3news'
      # …
```

See also: `\TYPO3\CMS\Dashboard\Widgets\Provider\ButtonProvider`.

-   **$title**

    -   *Type:* string

    The title used for the button. E.g. an `LLL:EXT:` reference like
    `LLL:EXT:dashboard/Resources/Private/Language/locallang.xlf:widgets.t3news.moreItems`.

-   **$link**

    -   *Type:* string

    The link to use for the button. Clicking the button will open the link.

-   **$target**

    -   *Type:* string

    The target of the link, e.g. `_blank`.
    `LLL:EXT:dashboard/Resources/Private/Language/locallang.xlf:widgets.t3news.moreItems`.

## Implementation {#adding-buttons-implementation}

An example implementation could look like this:

**Classes/Widgets/RssWidget.php**

```php
class RssWidget implements WidgetInterface
{
    public function __construct(
        // …
        private readonly ButtonProviderInterface $buttonProvider = null,
        // …
    ) {
    }

    public function renderWidgetContent(): string
    {
        // …
        $this->view->assignMultiple([
            // …
            'button' => $this->buttonProvider,
            // …
        ]);
        // …
    }

    public function getOptions(): array
    {
        return $this->options;
    }
}
```
