0 follower

Final Class Yiisoft\Yii\Bulma\Tabs

InheritanceYiisoft\Yii\Bulma\Tabs » Yiisoft\Widget\Widget

Simple responsive horizontal navigation tabs, with different styles.

echo Tabs::widget()
    ->alignment(Tabs::ALIGNMENT_CENTERED)
    ->size(Tabs::SIZE_LARGE)
    ->style(Tabs::STYLE_BOX)
    ->items([
        [
            'label' => 'Pictures',
            'icon' => 'fas fa-image',
            'active' => true,
            'content' => 'Some text about pictures',
            'contentAttributes' => [
                'class' => 'is-active',
            ],
        ],
        ['label' => 'Music', 'icon' => 'fas fa-music', 'content' => 'Some text about music'],
        ['label' => 'Videos', 'icon' => 'fas fa-film', 'content' => 'Some text about videos'],
        ['label' => 'Documents', 'icon' => 'far fa-file-alt', 'content' => 'Some text about documents'],
    ]);

Public Methods

Hide inherited methods

Method Description Defined By
alignment() Returns a new instance with the specified alignment the tabs list. Yiisoft\Yii\Bulma\Tabs
attributes() Returns a new instance with the specified HTML attributes for widget. Yiisoft\Yii\Bulma\Tabs
autoIdPrefix() Returns a new instance with the specified prefix to the automatically generated widget IDs. Yiisoft\Yii\Bulma\Tabs
currentPath() Returns a new instance with the specified current path. Yiisoft\Yii\Bulma\Tabs
deactivateItems() Returns a new instance with the specified disables active items according to their current path. Yiisoft\Yii\Bulma\Tabs
encode() Returns a new instance with the specified whether the tags for the tabs are encoded. Yiisoft\Yii\Bulma\Tabs
id() Returns a new instance with the specified ID of the widget. Yiisoft\Yii\Bulma\Tabs
items() Returns a new instance with the specified items. Yiisoft\Yii\Bulma\Tabs
itemsAttributes() Returns a new instance with the specified attributes of the items. Yiisoft\Yii\Bulma\Tabs
render() Yiisoft\Yii\Bulma\Tabs
size() Returns a new instance with the specified size of the tabs list. Yiisoft\Yii\Bulma\Tabs
style() Returns a new instance with the specified style of the tabs list. Yiisoft\Yii\Bulma\Tabs
tabsContentAttributes() Returns a new instance with the specified attributes of the tabs content. Yiisoft\Yii\Bulma\Tabs

Constants

Hide inherited constants

Constant Value Description Defined By
ALIGNMENT_ALL [ self::ALIGNMENT_CENTERED, self::ALIGNMENT_RIGHT, ] Yiisoft\Yii\Bulma\Tabs
ALIGNMENT_CENTERED 'is-centered' Yiisoft\Yii\Bulma\Tabs
ALIGNMENT_RIGHT 'is-right' Yiisoft\Yii\Bulma\Tabs
SIZE_ALL [ self::SIZE_SMALL, self::SIZE_MEDIUM, self::SIZE_LARGE, ] Yiisoft\Yii\Bulma\Tabs
SIZE_LARGE 'is-large' Yiisoft\Yii\Bulma\Tabs
SIZE_MEDIUM 'is-medium' Yiisoft\Yii\Bulma\Tabs
SIZE_SMALL 'is-small' Yiisoft\Yii\Bulma\Tabs
STYLE_ALL [ self::STYLE_BOX, self::STYLE_TOGGLE, self::STYLE_TOGGLE_ROUNDED, self::STYLE_FULLWIDTH, ] Yiisoft\Yii\Bulma\Tabs
STYLE_BOX 'is-boxed' Yiisoft\Yii\Bulma\Tabs
STYLE_FULLWIDTH 'is-fullwidth' Yiisoft\Yii\Bulma\Tabs
STYLE_TOGGLE 'is-toggle' Yiisoft\Yii\Bulma\Tabs
STYLE_TOGGLE_ROUNDED 'is-toggle is-toggle-rounded' Yiisoft\Yii\Bulma\Tabs

Method Details

Hide inherited methods

alignment() public method

Returns a new instance with the specified alignment the tabs list.

public self alignment ( string $value )
$value string

The alignment the tabs list. By default, not class is added and the size is considered "is-left". Possible values: Tabs::ALIGNMENT_CENTERED, Tabs::ALIGNMENT_RIGHT.

throws InvalidArgumentException

                public function alignment(string $value): self
{
    if (!in_array($value, self::ALIGNMENT_ALL, true)) {
        $values = implode('", "', self::ALIGNMENT_ALL);
        throw new InvalidArgumentException("Invalid alignment. Valid values are: \"$values\".");
    }
    $new = clone $this;
    $new->alignment = $value;
    return $new;
}

            
attributes() public method

Returns a new instance with the specified HTML attributes for widget.

public self attributes ( array $values )
$values array

Attribute values indexed by attribute names.

{@see \Yiisoft\Html\Html::renderTagAttributes()} For details on how attributes are being rendered.

                public function attributes(array $values): self
{
    $new = clone $this;
    $new->attributes = $values;
    return $new;
}

            
autoIdPrefix() public method

Returns a new instance with the specified prefix to the automatically generated widget IDs.

public self autoIdPrefix ( string $value )
$value string

The prefix to the automatically generated widget IDs.

                public function autoIdPrefix(string $value): self
{
    $new = clone $this;
    $new->autoIdPrefix = $value;
    return $new;
}

            
currentPath() public method

Returns a new instance with the specified current path.

public self currentPath ( string $value )
$value string

The current path.

                public function currentPath(string $value): self
{
    $new = clone $this;
    $new->currentPath = $value;
    return $new;
}

            
deactivateItems() public method

Returns a new instance with the specified disables active items according to their current path.

public self deactivateItems ( )

                public function deactivateItems(): self
{
    $new = clone $this;
    $new->activateItems = false;
    return $new;
}

            
encode() public method

Returns a new instance with the specified whether the tags for the tabs are encoded.

public self encode ( boolean $value )
$value boolean

Whether to encode the output.

                public function encode(bool $value): self
{
    $new = clone $this;
    $new->encode = $value;
    return $new;
}

            
id() public method

Returns a new instance with the specified ID of the widget.

public self id ( string $value )
$value string

The ID of the widget.

                public function id(string $value): self
{
    $new = clone $this;
    $new->attributes['id'] = $value;
    return $new;
}

            
items() public method

Returns a new instance with the specified items.

public self items ( array $value )
$value array

List of tabs items. Each tab item should be an array of the following structure:

  • label: string, required, the nav item label.
  • url: string, optional, the item's URL.
  • visible: bool, optional, whether this menu item is visible.
  • urlAttributes: array, optional, the HTML attributes of the item's link.
  • attributes: array, optional, the HTML attributes of the item container (LI).
  • active: bool, optional, whether the item should be on active state or not.
  • encode: bool, optional, whether the label will be HTML-encoded. If set, supersedes the $encode option for only this item.
  • icon: string, the tab item icon.
  • iconAttributes: array, optional, the HTML attributes of the item's icon.
  • rightSide: bool, position the icon to the right.
  • content: string, required if items is not set. The content (HTML) of the tab.
  • contentAttributes: array, array, the HTML attributes of the tab content container.

                public function items(array $value): self
{
    $new = clone $this;
    $new->items = $value;
    return $new;
}

            
itemsAttributes() public method

Returns a new instance with the specified attributes of the items.

public self itemsAttributes ( array $value )
$value array

List of HTML attributes for the items.

{@see \Yiisoft\Html\Html::renderTagAttributes()} For details on how attributes are being rendered.

                public function itemsAttributes(array $value): self
{
    $new = clone $this;
    $new->itemsAttributes = $value;
    return $new;
}

            
render() public method

public string render ( )

                public function render(): string
{
    $attributes = $this->attributes;
    $id = Html::generateId($this->autoIdPrefix) . '-tabs';
    if (array_key_exists('id', $attributes)) {
        /** @var string */
        $id = $attributes['id'];
        unset($attributes['id']);
    }
    Html::addCssClass($attributes, 'tabs');
    if ($this->size !== '') {
        Html::addCssClass($attributes, $this->size);
    }
    if ($this->alignment !== '') {
        Html::addCssClass($attributes, $this->alignment);
    }
    if ($this->style !== '') {
        Html::addCssClass($attributes, $this->style);
    }
    return Div::tag()
        ->attributes($attributes)
        ->content(PHP_EOL . $this->renderItems() . PHP_EOL)
        ->id($id)
        ->encode(false)
        ->render() . $this->renderTabsContent();
}

            
size() public method

Returns a new instance with the specified size of the tabs list.

public self size ( string $value )
$value string

Size class. By default, not class is added and the size is considered "normal". Possible values: Tabs::SIZE_SMALL, Tabs::SIZE_MEDIUM, Tabs::SIZE_LARGE.

{@see \Yiisoft\Yii\Bulma\self::SIZE_ALL}

throws InvalidArgumentException

                public function size(string $value): self
{
    if (!in_array($value, self::SIZE_ALL, true)) {
        $values = implode('", "', self::SIZE_ALL);
        throw new InvalidArgumentException("Invalid size. Valid values are: \"$values\".");
    }
    $new = clone $this;
    $new->size = $value;
    return $new;
}

            
style() public method

Returns a new instance with the specified style of the tabs list.

public self style ( string $value )
$value string

The style of the tabs list. By default, not class is added and the size is considered "normal". Possible values: Tabs::STYLE_BOX, Tabs::STYLE_TOGGLE, Tabs::STYLE_TOGGLE_ROUNDED, Tabs::STYLE_FULLWIDTH.

throws InvalidArgumentException

                public function style(string $value): self
{
    if (!in_array($value, self::STYLE_ALL, true)) {
        $values = implode('", "', self::STYLE_ALL);
        throw new InvalidArgumentException("Invalid alignment. Valid values are: \"$values\".");
    }
    $new = clone $this;
    $new->style = $value;
    return $new;
}

            
tabsContentAttributes() public method

Returns a new instance with the specified attributes of the tabs content.

public self tabsContentAttributes ( array $value )
$value array

List of HTML attributes for the tabs-content container. This will always contain the CSS class tabs-content.

{@see \Yiisoft\Html\Html::renderTagAttributes()} For details on how attributes are being rendered.

                public function tabsContentAttributes(array $value): self
{
    $new = clone $this;
    $new->tabsContentAttributes = $value;
    return $new;
}