How elements and immutability work
mainHTML elements (found in the Spatie\Html\Elements namespace) are typically created using a Spatie\Html\Html builder instance.
Immutability: Element instances are immutable. When you call a fluent method to modify attributes or contents, it returns a new instance rather than modifying the existing one. To capture changes, you must assign the result to a variable.
$icon = html()->span()->class('fa');
// This returns a NEW instance with both classes applied
$icon->class('fa-eye'); // '<span class="fa fa-eye"></span>'
// This returns a NEW instance with the slash class applied
$icon->class('fa-eye-slash'); // '<span class="fa fa-eye-slash"></span>'html()->span()->text('Hello world!');