Skip to content

Latest commit

 

History

History
134 lines (95 loc) · 5.45 KB

File metadata and controls

134 lines (95 loc) · 5.45 KB

I

The <i> HTML element represents a range of text that's set off from the normal text for some reason, such as an idiomatic text, technical terms, taxonomic designations, among others.

Basic Usage

Instantiate the I class using I::widget().

$i = I::widget();

Setting Attributes

Use the provided methods to set specific attributes for the a element.

// setting class attribute
$i->class('fa fa-home');

Or, use the attributes method to set multiple attributes at once.

$i->attributes(['class' => 'fa fa-home', 'aria-hidden' => 'true']);

Adding Content

If you want to include content within the i tag, use the content method.

$i->content('->');

Rendering

Generate the HTML output using the render method.

$html = $i->render();

Or, use the magic __toString method.

$html = (string) $i;

Common Use Cases

Below are examples of common use cases:

// adding multiple attributes
$i->class('fa fa-home')->title('Home');

// using data attributes
$i->dataAttributes(['bs-toggle' => 'modal', 'bs-target' => '#exampleModal', 'analytics' => 'trackClick']);

Explore additional methods for setting various attributes such as lang, tabindex, title, and more.

Prefix and Suffix

Use prefix and suffix methods to add text before and after the i tag, respectively.

// adding a prefix
$html = $i->content('->')->prefix('Next')->render();

// adding a suffix
$html = $i->content('<-')->suffix('Previous')->render();

Template

The template method allows you to customize the HTML output of the a element.

The following template tags are available:

Tag Description
{prefix} The prefix text.
{tag} The a element.
{suffix} The suffix text.
// using a custom template
$i->template('<span>{tag}</span>');

Attributes

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 i 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.

Custom methods

Refer to the Custom Method Test for comprehensive examples.

The following methods are available for customizing the HTML output:

Method Description
prefix() Add text before the i element.
prefixContainer() Set enabled or disabled for the prefix-container element.
prefixContainerAttributes() Set attributes for the prefix-container element.
prefixContainerClass() Set the class attribute for the prefix-container element.
prefixContainerTag() Set the tag for the prefix-container element.
render() Generates the HTML output.
suffix() Add text after the i element.
suffixContainer() Set enabled or disabled for the suffix-container element.
suffixContainerAttributes() Set attributes for the suffix-container element.
suffixContainerClass() Set the class attribute for the suffix-container element.
suffixContainerTag() Set the tag for the suffix-container element.
template() Set the template for the i element.
widget() Instantiates the I::class.