The <ul> HTML element represents an unordered list of items, typically rendered as a bulleted list.
Instantiate the Ul class using Ul::widget().
$ul = Ul::widget();Use the provided methods to set specific attributes for the a element.
// setting class attribute
$ul->class('container');Or, use the attributes method to set multiple attributes at once.
$ul->attributes(['class' => 'container', 'style' => 'background-color: #eee;']);If you want to include content within the div tag, use the content method.
$ul->content('MyContent');Generate the HTML output using the render method, for simple instantiation.
$html = $ul->render();Or, use the magic __toString method.
$html = (string) $ul;Below are examples of common use cases:
// adding multiple attributes
$ul->class('external')->content('MyContent');Explore additional methods for setting various attributes such as lang, name, style, title, type, etc.
Refer to the Attribute Tests for comprehensive examples.
The following methods are available for setting attributes:
| Method | Description |
|---|---|
attributes() |
Set multiple attributes at once. |
class() |
Set the class attribute. |
content() |
Set the content within the div element. |
dataAttributes() |
Set multiple data-attributes at once. |
id() |
Set the id attribute. |
lang() |
Set the lang attribute. |
name() |
Set the name attribute. |
style() |
Set the style attribute. |
title() |
Set the title attribute. |
type() |
Set the type attribute. |
| Allowed values: |
Refer to the Custom Methods Tests for comprehensive examples.
The following methods are available for customizing the HTML output:
| Method | Description |
|---|---|
render() |
Generates the HTML output. |
widget() |
Instantiates the Ul::class. |