DropDownButton

class \TYPO3\CMS\Backend\Template\Components\Buttons\DropDownButton

Implements
ButtonInterface

This button type is a container for dropdown items.

It will render a dropdown containing all items attached to it. There are different kinds available, each item needs to implement the DropDownItemInterface. When this type contains elements of type DropDownRadio it will use the icon of the first active item of this type.

Example:

public function __construct(
    protected readonly ComponentFactory $componentFactory,
) }

public function myAction(): ResponseInterface
{
    $buttonBar = $this->moduleTemplate->getDocHeaderComponent()->getButtonBar();
    $dropDownButton = $this->componentFactory->createDropDownButton()
         ->setLabel('Dropdown')
         ->setTitle('Save')
         ->setIcon($this->iconFactory->getIcon('actions-heart'))
         ->setShowLabelText(true)
         ->addItem(
             $this->componentFactory->createDropDownItem()
                 ->setLabel('Item')
                 ->setHref('#')
         );
    $buttonBar->addButton($dropDownButton, ButtonBar::BUTTON_POSITION_RIGHT, 2);
}

Table of Contents

Interfaces

ButtonInterface
Interface for buttons in the document header.

Properties

$disabled  : bool
$icon  : Icon|null
$items  : array
$label  : string
$showActiveLabelText  : bool
$showLabelText  : bool
$size  : ButtonSize
$title  : string|null

Methods

__toString()  : string
addItem()  : static
getIcon()  : Icon|null
getItems()  : DropDownItemInterface[]
getLabel()  : string
getShowActiveLabelText()  : bool
getShowLabelText()  : bool
getSize()  : ButtonSize
getTitle()  : string
getType()  : string
Returns the fully qualified class name as the component type identifier.
isDisabled()  : bool
isValid()  : bool
Validates whether the component is properly configured and can be rendered.
render()  : string
Renders the component as an HTML string.
setDisabled()  : static
setIcon()  : static
setLabel()  : static
setShowActiveLabelText()  : static
setShowLabelText()  : static
setSize()  : DropDownButton
setTitle()  : static

Properties

$showActiveLabelText

protected bool $showActiveLabelText = false

$showLabelText

protected bool $showLabelText = false

$size

protected ButtonSize $size = \TYPO3\CMS\Backend\Template\Components\Buttons\ButtonSize::SMALL

Methods

__toString()

public __toString() : string

Return values

string

getLabel()

public getLabel() : string

Return values

string

getShowActiveLabelText()

public getShowActiveLabelText() : bool

Return values

bool

getShowLabelText()

public getShowLabelText() : bool

Return values

bool

getTitle()

public getTitle() : string

Return values

string

getType()

Returns the fully qualified class name as the component type identifier.

public getType() : string

This is used to identify the specific component type in validation and rendering.

Return values

string —

The fully qualified class name (e.g., 'TYPO3\CMS\Backend\Template\Components\Buttons\LinkButton')

isDisabled()

public isDisabled() : bool

Return values

bool

isValid()

Validates whether the component is properly configured and can be rendered.

public isValid() : bool

Each implementing class defines its own validation rules (e.g., required fields).

Return values

bool —

True if the component is valid and can be rendered, false otherwise

render()

Renders the component as an HTML string.

public render() : string

This method should only be called after validating the component with isValid(). The returned HTML is ready to be output to the browser.

Return values

string —

The rendered HTML markup

setDisabled()

public setDisabled(bool $disabled) : static

Parameters

$disabled : bool

Return values

static

setIcon()

public setIcon(Icon|null $icon) : static

Parameters

$icon : Icon|null

Return values

static

setLabel()

public setLabel(string $label) : static

Parameters

$label : string

Return values

static

setShowActiveLabelText()

public setShowActiveLabelText(bool $showActiveLabelText) : static

Parameters

$showActiveLabelText : bool

Return values

static

setShowLabelText()

public setShowLabelText(bool $showLabelText) : static

Parameters

$showLabelText : bool

Return values

static

setTitle()

public setTitle(string|null $title) : static

Parameters

$title : string|null

Return values

static
On this page