LinkButton extends AbstractButton
This button type renders a regular anchor tag with TYPO3s way to render a button control.
Example:
public function __construct(
protected readonly ComponentFactory $componentFactory,
) }
public function myAction(): ResponseInterface
{
$buttonBar = $this->moduleTemplate->getDocHeaderComponent()->getButtonBar();
$saveButton = $this->componentFactory->createLinkButton()
->setHref('#')
->setDataAttributes([
'foo' => 'bar'
])
->setIcon($this->iconFactory->getIcon('actions-document-save', IconSize::SMALL))
->setTitle('Save');
$buttonBar->addButton($saveButton, ButtonBar::BUTTON_POSITION_LEFT, 1);
}
Table of Contents
Properties
- $attributes : array<string|int, mixed>
- Attributes for the button
- $classes : string
- CSS classes to apply to the rendered element
- $dataAttributes : array<string, string>
- HTML data-* attributes for the control
- $disabled : bool
- Whether the button is in disabled state
- $href : string
- $icon : Icon|null
- Optional icon to display on the button
- $role : string
- $showLabelText : bool
- Whether to show the button's label text (from title property).
- $size : ButtonSize
- $title : string
- Title/label text for the control
Methods
- __toString() : string
- Implementation from ButtonInterface This object is an abstract, so no implementation is necessary
- getAttributes() : array<string, string>
- getClasses() : string
- getDataAttributes() : array<string|int, mixed>
- getHref() : string
- getIcon() : Icon|null
- getRole() : string
- getShowLabelText() : bool
- getSize() : ButtonSize
- getTitle() : string
- getType() : string
- Returns the fully qualified class name as the component type identifier.
- isDisabled() : bool
- isValid() : bool
- Implementation from ButtonInterface This object is an abstract, so no implementation is necessary
- render() : string
- Implementation from ButtonInterface This object is an abstract, so no implementation is necessary
- setAttributes() : static
- setClasses() : static
- setDataAttributes() : static
- setDisabled() : static
- setHref() : static
- setIcon() : static
- setRole() : static
- setShowLabelText() : static
- setSize() : static
- setTitle() : static
Properties
$attributes
Attributes for the button
protected
array<string|int, mixed>
$attributes
= []
$classes
CSS classes to apply to the rendered element
protected
string
$classes
= ''
$dataAttributes
HTML data-* attributes for the control
protected
array<string, string>
$dataAttributes
= []
Key-value pairs (e.g., ['action' => 'save'])
$disabled
Whether the button is in disabled state
protected
bool
$disabled
= false
$href
protected
string
$href
= ''
$icon
Optional icon to display on the button
protected
Icon|null
$icon
= null
$role
protected
string
$role
= 'button'
$showLabelText
Whether to show the button's label text (from title property).
protected
bool
$showLabelText
= false
If false, only the icon is shown (label is used for title attribute).
$size
protected
ButtonSize
$size
= \TYPO3\CMS\Backend\Template\Components\Buttons\ButtonSize::SMALL
$title
Title/label text for the control
protected
string
$title
= ''
Methods
__toString()
Implementation from ButtonInterface This object is an abstract, so no implementation is necessary
public
__toString() : string
Return values
stringgetAttributes()
public
getAttributes() : array<string, string>
Return values
array<string, string>getClasses()
public
getClasses() : string
Return values
stringgetDataAttributes()
public
getDataAttributes() : array<string|int, mixed>
Return values
array<string|int, mixed>getHref()
public
getHref() : string
Return values
stringgetIcon()
public
getIcon() : Icon|null
Return values
Icon|nullgetRole()
public
getRole() : string
Return values
stringgetShowLabelText()
public
getShowLabelText() : bool
Return values
boolgetSize()
public
getSize() : ButtonSize
Return values
ButtonSizegetTitle()
public
getTitle() : string
Return values
stringgetType()
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
boolisValid()
Implementation from ButtonInterface This object is an abstract, so no implementation is necessary
public
isValid() : bool
Return values
bool —True if the component is valid and can be rendered, false otherwise
render()
Implementation from ButtonInterface This object is an abstract, so no implementation is necessary
public
render() : string
Return values
stringsetAttributes()
public
setAttributes(array<string, string> $attributes) : static
Parameters
- $attributes : array<string, string>
Return values
staticsetClasses()
public
setClasses(string $classes) : static
Parameters
- $classes : string
Return values
staticsetDataAttributes()
public
setDataAttributes(array<string|int, mixed> $dataAttributes) : static
Parameters
- $dataAttributes : array<string|int, mixed>
Return values
staticsetDisabled()
public
setDisabled(bool $disabled) : static
Parameters
- $disabled : bool
Return values
staticsetHref()
public
setHref(string $href) : static
Parameters
- $href : string
Return values
staticsetIcon()
public
setIcon(Icon|null $icon) : static
Parameters
- $icon : Icon|null
Return values
staticsetRole()
public
setRole(string $role) : static
Parameters
- $role : string
Return values
staticsetShowLabelText()
public
setShowLabelText(bool $showLabelText) : static
Parameters
- $showLabelText : bool
Return values
staticsetSize()
public
setSize(ButtonSize $size) : static
Parameters
- $size : ButtonSize
Return values
staticsetTitle()
public
setTitle(string $title) : static
Parameters
- $title : string