---
title: "UI Components"
url: https://festi.dev/8.0/Packages/Theme/docs/UIComponents/
---

# UI Components

The Festi Theme offers a variety of reusable UI components for building robust and customizable interfaces.

This page lists the methods of each component. The [HUI guide](https://festi.dev/8.0/Packages/Theme/docs/HUI/index.md) tells you how the components work, how to replace a component template, and how to add a component.

Each component also has these methods: `fetch()`, `setID()`, `getID()`, `setCSS()`, `getCSS()`, `addDataAttribute()`, `removeDataAttribute()`, `setDataAttributes()`, `getDataAttributes()`.

- [Basic Components](#basic-components)
  - [Guide Block](#guide-block)
  - [Breadcrumbs](#breadcrumbs)
  - [Button](#button)
  - [Buttons](#buttons)
  - [Link](#link)
  - [Dropdown](#dropdown)
  - [Sparks](#sparks)
  - [Slider](#slider)
- [Form Components](#form-components)
  - [Input](#input)
  - [Select](#select)
  - [Checkbox](#checkbox)
  - [Checkboxes](#checkboxes)
  - [Textarea](#textarea)
  - [Filter Panel](#filter-panel)
- [Layout Components](#layout-components)
  - [Block](#block)
  - [Widget](#widget)
  - [Dialog](#dialog)
  - [Card](#card)
  - [Tabs](#tabs)
  - [Main Navbar](#main-navbar)
- [Display Components](#display-components)
  - [Message](#message)
  - [Data List](#data-list)
  - [Filter](#filter)

## Basic Components

### Guide Block
A component for displaying informational blocks with icons and descriptions.

![Guide Block Component](https://festi.dev/8.0/Packages/Theme/docs/images/ui-guide-block-component.png)

**Methods:**

Sets the icon path for the guide block
```php
public function setIcon(string $icon): IGuideBlock;
```

Sets the title text for the guide block
```php
public function setTitle(string $title): IGuideBlock;
```

Sets the descriptive text for the guide block
```php
public function setDescription(string $description): IGuideBlock;
```

**Example:**
```php
$this->ui->guideBlock()
    ->setIcon('/path/to/icon.png')
    ->setTitle('Title')
    ->setDescription('Description')
    ->fetch();
```

### Breadcrumbs
Navigation component showing the current page location hierarchy.

![Breadcrumbs Component](https://festi.dev/8.0/Packages/Theme/docs/images/ui-breadcrumbs-component.png)

**Methods:**

Sets the navigation items array where keys are labels and values are URLs (false for current page)
```php
public function setItems(array $items): IBreadcrumbs;
```

Sets additional content to be displayed on the right side of the breadcrumbs
```php
public function setRight(string $content): IBreadcrumbs;
```

**Example:**
```php
$items = [
    'Home' => '/url/to/home',
    'Current Page' => false // false indicates current page
];
$this->ui->breadcrumbs()
    ->setItems($items)
    ->setRight('Additional content')
    ->fetch();
```

### Button
Single button component with customizable attributes.

**Methods:**

Sets the text displayed on the button
```php
public function setCaption(string $caption): IButton;
```

Sets the URL that the button links to
```php
public function setUrl(string $url): IButton;
```

Sets a unique identifier for the button
```php
public function setId(string $id): IButton;
```

Sets the button type (e.g., 'submit', 'button', 'reset')
```php
public function setType(string $type): IButton;
```

Sets CSS classes for styling the button
```php
public function setCSS(string $css): IButton;
```

Sets the disabled attribute
```php
public function setDisabled(bool $isDisabled = true): IButton;
```

Sets the Font Awesome icon name, without the prefix `fa-`
```php
public function setIcon(?string $icon): IButton;
```

Sets the JavaScript for the `onclick` attribute. `setUrl()` has priority over `setClick()`.
```php
public function setClick(string $js): IButton;
```

Gets the current button type
```php
public function getType(): ?string;
```

**Example:**
```php
$this->ui->button()
    ->setCaption('Click Me')
    ->setType('submit')
    ->setCSS('btn-primary')
    ->setUrl('/action/url')
    ->setId('uniqueButtonId')
    ->setDisabled()
    ->fetch();
```

### Buttons
Component for grouping multiple buttons together.

**Methods:**

Sets an array of button components to be displayed as a group
```php
public function setItems(array $items): IButtons;
```

### Link
Hyperlink component for creating clickable links with customizable attributes.

**Methods:**

Sets the URL that the link points to
```php
public function setHref(string $href): ILink;
```

Sets the target attribute for the link (e.g., '_blank', '_self', '_parent', '_top')
```php
public function setTarget(string $target): ILink;
```

Sets the text displayed for the link
```php
public function setCaption(string $caption): ILink;
```

Sets CSS classes for styling the link
```php
public function setCSS(string $css): ILink;
```

Sets a unique identifier for the link
```php
public function setID(int|string $id): ILink;
```

Sets the title attribute for the link
```php
public function setTitle(string $title): ILink;
```

**Example:**
```php
$this->ui->link()
    ->setHref('/dashboard/users/')
    ->setCaption('View Users')
    ->setTitle('View Users')
    ->setTarget('_blank')
    ->setCSS('btn-default')
    ->setID('users-link')
    ->fetch();
```

### Dropdown
Bootstrap-style dropdown menu component with customizable trigger and menu items.

**Methods:**

Sets the caption text for the dropdown trigger button
```php
public function setCaption(string $caption): IDropdown;
```

Sets an array of menu items to be displayed in the dropdown
```php
public function setItems(array $items): IDropdown;
```

Sets the alignment of the dropdown menu ('left', 'right')
```php
public function setAlign(string $align): IDropdown;
```

Sets CSS classes for styling the dropdown
```php
public function setCSS(string $css): IDropdown;
```

Sets a unique identifier for the dropdown
```php
public function setID(int|string $id): IDropdown;
```

**Example:**
```php
$items = [
    $this->ui->link()->setHref('/books/edit/')->setCaption('Edit'),
    $this->ui->link()->setHref('/books/delete/')->setCaption('Delete')->setDataAttributes(['confirm' => 'Are you sure?'])
];

$this->ui->dropdown()
    ->setCaption('Actions')
    ->setItems($items)
    ->setAlign('right')
    ->setCSS('dropdown-menu-end')
    ->setID('actions-dropdown')
    ->setDataAttributes(['toggle' => 'dropdown'])
    ->fetch();
```

**Rendered HTML:**
```html
<div class="fui-buttons pull-right dropdown-menu-end" id="actions-dropdown" data-toggle="dropdown">
    <button type="button" class="btn btn-default dropdown-toggle" data-toggle="dropdown">
        Actions
        <span class="caret"></span>
    </button>
    <ul class="dropdown-menu pull-right" role="menu">
        <li><a href="/edit">Edit</a></li>
        <li><a href="/delete" data-confirm="Are you sure?">Delete</a></li>
    </ul>
</div>
```

### Sparks
Component for displaying metric indicators and statistics.

![Sparks Component](https://festi.dev/8.0/Packages/Theme/docs/images/ui-sparks-component.png)

**Methods:**

Sets the array of spark items to display
```php
public function setItems(array $items): ISparks;
```

**Example:**
```php
$items = [
    ['Users', '150', '+10%'],
    ['Revenue', '$1000', '+5%']
];
$this->ui->sparks()
    ->setItems($items)
    ->fetch();
```

### Slider
Component for displaying a horizontal slider/carousel of items with optional caption and "View all" link.
Each item is automatically wrapped in a `e-slider-item` box defined in the slider template.
Any `IUIElement` can be passed as a slider item (e.g. `card()`, `message()`, `widget()`).

![Slider Component](https://festi.dev/8.0/Packages/Theme/docs/images/ui-slider-component.png)

**Methods:**

Sets the caption text displayed in the slider header
```php
public function setCaption(string $caption): ISlider;
```

Sets the array of `IUIElement` items to be displayed in the slider. Throws `InvalidArgumentException` if any element does not implement `IUIElement`
```php
public function setItems(array $items): ISlider;
```

Appends a single `IUIElement` to the slider
```php
public function addItem(IUIElement $item): ISlider;
```

Sets the URL for the "View all" link displayed in the slider header
```php
public function setHref(string $href): ISlider;
```

Sets a custom caption for the "View all" link (default: `ISlider::DEFAULT_HREF_CAPTION`)
```php
public function setHrefCaption(string $caption): ISlider;
```

Sets a custom message shown when the slider has no items (default: `ISlider::DEFAULT_EMPTY_ITEMS_TEXT`)
```php
public function setEmptyItemsText(string $text): ISlider;
```

Hides the empty state message entirely when there are no items
```php
public function hideEmptyItemsText(): ISlider;
```

**Example:**
```php
$slider = $this->ui->slider()
    ->setCaption('Recent posts')
    ->setHref('/posts')
    ->setHrefCaption('See all')
    ->setID('my-slider')
    ->setDataAttributes(['module' => 'slider']);

$slider->addItem(
    $this->ui->card()->setCaption('First item')->setInfo('First description')
);
$slider->addItem(
    $this->ui->card()->setCaption('Second item')->setInfo('Second description')
);

echo $slider->fetch();
```

**Empty state:**
```php
// Custom message
$this->ui->slider()
    ->setItems([])
    ->setEmptyItemsText('No posts yet')
    ->fetch();

// Hide empty state completely
$this->ui->slider()
    ->setItems([])
    ->hideEmptyItemsText()
    ->fetch();
```

## Form Components

### Input
Basic input field component with extensive customization options.

**Methods:**

Sets the name attribute of the input field
```php
public function setName(string $name): self;
```

Gets the current name of the input field
```php
public function getName(): string;
```

Sets the label text for the input field
```php
public function setCaption(string $caption): self;
```

Gets the current label text
```php
public function getCaption(): ?string;
```

Sets placeholder text shown when the input is empty
```php
public function setPlaceholder(string $placeholder): self;
```

Gets the current placeholder text
```php
public function getPlaceholder(): ?string;
```

Sets the input type (see Available Types below)
```php
public function setType(string $type): self;
```

Gets the current input type
```php
public function getType(): ?string;
```

Sets the input value
```php
public function setValue($value): self;
```

Gets the current input value
```php
public function getValue();
```

Sets whether the input is required
```php
public function setRequired(bool $isRequired): self;
```

Gets whether the input is required
```php
public function isRequired(): bool;
```

Gets the formatted display value of the input
```php
public function getDisplayValue(): mixed;
```

Sets a disclaimer note displayed below the input field
```php
public function setDisclaimer(string $disclaimer): self;
```

Gets the current disclaimer text
```php
public function getDisclaimer(): ?string;
```

**Available Types:**

- `IInput::TYPE_TEXT`: Text input
- `IInput::TYPE_NUMBER`: Number input
- `IInput::TYPE_TEXTAREA`: Textarea input
- `IInput::TYPE_MONTH`: Month picker
- `IInput::TYPE_DATE`: Date picker
- `IInput::TYPE_SELECT`: Select dropdown
- `IInput::TYPE_CHECKBOX`: Checkbox input
- `IInput::TYPE_HIDDEN`: Hidden input

### Select
Dropdown select component with support for multiple selection.

**Methods:**

Sets the available options for selection
```php
public function setOptions(array $options): self;
```

Gets the current options array
```php
public function getOptions(): array;
```

Enables or disables multiple selection
```php
public function setMultiple(bool $isMultiple): self;
```

Checks if multiple selection is enabled
```php
public function isMultiple(): bool;
```

Shows or hides the empty option at the top of the list
```php
public function setShowEmpty(bool $showEmpty): self;
```

Checks if empty option is shown
```php
public function isShowEmpty(): bool;
```

Gets the formatted display value of selected option(s)
```php
public function getDisplayValue(): mixed;
```

### Checkbox
Single checkbox input component.

**Methods:**

Sets the checked state of the checkbox
```php
public function setChecked(bool $isChecked): self;
```

Gets the current checked state
```php
public function isChecked(): bool;
```

### Checkboxes
Component for grouping multiple checkboxes.

**Methods:**

Adds a checkbox input to the group
```php
public function addCheckbox(ICheckbox $input): self;
```

Gets all checkboxes in the group
```php
public function getCheckboxes(): array;
```

### Textarea
Text area input component that extends the base Input component.

**Methods:**

Sets the number of rows for the textarea
```php
public function setRows(int $rows): self;
```

Gets the current number of rows
```php
public function getRows(): int;
```

**Example:**
```php
$this->ui->textarea()
    ->setName('description')
    ->setValue('Default text')
    ->setRows(5)
    ->fetch();
```

### Filter Panel
Advanced filtering interface with customizable fields and actions.

![Filter Panel Component](https://festi.dev/8.0/Packages/Theme/docs/images/ui-filter-panel-component.png)

**Methods:**

Sets the filter input fields
```php
public function setFields(array $fields): self;
```

Gets the current filter fields
```php
public function getFields(): array;
```

Sets the form action URL
```php
public function setAction(string $action): self;
```

Gets the current form action URL
```php
public function getAction(): string;
```

**Example:**
```php
$fields = [
    $this->ui->input()->setName('search')->setPlaceholder('Search...'),
    $this->ui->select()->setName('status')->setOptions(['active' => 'Active', 'inactive' => 'Inactive'])
];

$this->ui->filterPanel()
    ->setFields($fields)
    ->setAction('/filter')
    ->fetch();
```

## Layout Components

### Block
Container component for structuring content with a title.

**Methods:**

Sets the title of the block
```php
public function setTitle(string $title): IBlock;
```

Sets the main content of the block
```php
public function setContent(string $content): IBlock;
```

### Widget
Component for displaying various types of content within a web page.

![Widget Component](https://festi.dev/8.0/Packages/Theme/docs/images/ui-widget-component.png)

**Methods:**

Sets the widget's title
```php
public function setTitle(string $title): IWidget;
```

Sets the main content of the widget
```php
public function setContent(string $content): IWidget;
```

Sets the toolbar content of the widget
```php
public function setToolbar(string $toolbar): IWidget;
```

### Dialog
Modal dialog component with customizable content and fields.

![Dialog Component](https://festi.dev/8.0/Packages/Theme/docs/images/ui-dialog-component.png)

**Methods:**

Sets the dialog title
```php
public function setTitle(string $title): IDialog;
```

Sets the submit button caption (false to hide)
```php
public function setSubmitCaption(string|bool $caption): IDialog;
```

Sets the main content of the dialog
```php
public function setBody(string $body): IDialog;
```

Sets the form submission URL
```php
public function setUrl(string $url): IDialog;
```

Sets a unique identifier for the dialog
```php
public function setId(string $id): IDialog;
```

Sets the close button caption (false to hide)
```php
public function setCloseCaption(string|bool $caption): IDialog;
```

Sets whether the dialog is initially hidden
```php
public function setHidden(bool $isHidden): IDialog;
```

Adds an input field to the dialog
```php
public function addField(string $name, IInput $field): IDialog;
```

Adds a hidden input field to the dialog
```php
public function addHiddenField(string $key, IInput $field): IDialog;
```

### Card
Component for displaying a card with title, info, and optional actions.

![Card Component](https://festi.dev/8.0/Packages/Theme/docs/images/ui-card-component.png)

**Methods:**

Sets the card's caption text
```php
public function setCaption(string $caption): ICard;
```

Sets the card's information content
```php
public function setInfo(string $info): ICard;
```

Sets CSS classes for styling the card
```php
public function setCSS(string $css): ICard;
```

Sets the card's title
```php
public function setTitle(string $title): IWidget;
```

### Tabs
A Bootstrap tab set. The component renders the list of tabs and one pane for each tab. The `id` of a pane is `<prefix><ident>`.

**Methods:**

Adds a tab
```php
public function addTab(string $ident, ?string $caption = null, ?string $content = null): ITabs;
```

Removes a tab
```php
public function removeTab(string $tabIdent): ITabs;
```

Sets the active tab. The default is the first tab.
```php
public function setActiveTab(?string $tabIdent): ITabs;
```

Sets the prefix of the pane `id`
```php
public function setTabPrefix(?string $prefix): ITabs;
```

Returns the tabs
```php
public function getTabs(): array;
```

**Example:**
```php
echo $this->ui->tabs()
    ->setTabPrefix('order-')
    ->addTab('details', __('Details'), $this->fetch('order_details.phtml'))
    ->addTab('history', __('History'), $this->fetch('order_history.phtml'))
    ->setActiveTab('details')
    ->fetch();
```

### Main Navbar
The top navigation bar of a website theme.

**Methods:**

```php
public function setLogoUrl(string $logo): IMainNavbar;
public function setLogoTitle(string $logoTitle): IMainNavbar;
public function setMainUrl(string $mainUrl): IMainNavbar;
public function setMenuItems(?array $menuItems): IMainNavbar;   // IMenuItem[]
public function setSearchUrl(?string $searchUrl): IMainNavbar;
public function setSearchPlaceholder(?string $searchPlaceholder): IMainNavbar;
```

## Display Components

### Message
Component for displaying status messages or alerts.

![Message Component](https://festi.dev/8.0/Packages/Theme/docs/images/ui-message-component.png)

**Methods:**

Sets the message type (success, error, warning, info)
```php
public function setType(string $type): IMessage;
```

Sets the message content to be displayed
```php
public function setMessage(string $message): IMessage;
```

Sets the icon to be displayed
```php
public function setShowIcon(bool $isShow = true): IMessage;
```

Sets the icon content
```php
public function setIcon(string $iconName): IMessage;
```

Sets the close button to be displayed
```php
public function setCloseButton(bool $isShowCloseButton): IMessage;
```
**Example:**
```php
echo $ui->message()
        ->setMessage($errorMessage)
        ->setType('danger')
        ->setCloseButton(true)
        ->setShowIcon(true)
        ->setIcon('exclamation-triangle')
        ->fetch();
```

### Data List
Component for displaying tabular data with columns and rows.

![Data List Component](https://festi.dev/8.0/Packages/Theme/docs/images/ui-datalist-component.png)

**Methods:**

Sets the column definitions for the table
```php
public function setColumns(array $columns): IDataList;
```

Sets the data rows to be displayed
```php
public function setRows(array $rows): IDataList;
```

### Filter
> **DEPRECATED**: This component is deprecated. Please use [Filter Panel](#filter-panel) component instead.

Component for creating advanced filtering interfaces.

![Filter Panel Component](https://festi.dev/8.0/Packages/Theme/docs/images/ui-filter-component.png)

**Methods:**

Sets the filter panel title
```php
public function setTitle(string $title): IFilter;
```

Sets the filter fields to be displayed
```php
public function setFields(array $fields): IFilter;
```

Sets CSS classes for styling the filter panel
```php
public function setCSS(string $css): self;
```

**Example using the recommended Filter Panel instead:**
```php
// Instead of using Filter component:
// $this->ui->filter()...

// Use Filter Panel component:
$fields = [
    $this->ui->input()->setName('search')->setPlaceholder('Search...'),
    $this->ui->select()->setName('status')->setOptions(['active' => 'Active', 'inactive' => 'Inactive'])
];

$this->ui->filterPanel()
    ->setFields($fields)
    ->setAction('/filter')
    ->fetch();
```

## Custom Components

A project or a plugin adds its own component without a `UIEngine` subclass.

1. Make a class that extends `HuiComponent` (or an existing component).
2. Put its template in `templates/ui/` of the plugin or of the theme.
3. Create it through the engine:

```php
$badge = $this->ui->create(BadgeHui::class, 'ui/badge.phtml');

echo $badge->setCaption('New')->fetch();
```

`create()` accepts a class that implements `IUIElement` and throws `ThemeException` for any other class.
The template is searched in the same directories as for the built-in components.

To give every plugin or the theme an engine with its own methods, override `createUIEngine()` in the plugin
(`DisplayPlugin`) or in the theme class (`DefaultTheme`).
