Skip to content
PHP Ecosystem
Explore

CanBeAutofocus

API reference › HTML Attribute › Global › CanBeAutofocus

traitUIAwesome\Html\Attribute\Global\CanBeAutofocus
Sourcesrc/Global/CanBeAutofocus.php
Used by 18 types

Provides an immutable API for the autofocus attribute.

See also: https://developer.mozilla.org/en-US/docs/Web/HTML/Global_attributes/autofocus.

MethodDescriptionDefined by
autofocus()Sets the autofocus attribute.CanBeAutofocus
public function autofocus(bool|null $value): static

Sets the autofocus attribute.

Parameters

ParameterTypeDescription
$valuebool|nullWhether to enable autofocus. Use true to enable, false to disable, or null to remove the attribute.

Returns

static: New instance with the updated autofocus attribute.