# Кнопка

**class** ![](/files/ERv3mwcF952ee1JOvr7d) `UXButton`(`php\gui\UXButton`) **extends** UXButton.

```php
use php\gui\UXButton;
```

`Button` - это класс компонента для отображения обычных текстов без форматирования, с возможностью выбора шрифта и иконки для текста. Он предоставляет базовый функционал для создания кнопок в пользовательском интерфейсе.

Изображение компонента:

![](/files/PCoRSkdo2ZndlQy62f86)

***

## **Свойства компонента**

* `-> text`
* `-> font`
* `-> underline`
* `-> wrapText`
* `-> textAlignment`
* `-> alignment`
* `-> graphic`
* `-> graphicTextGap`
* `-> contentDisplay`

***

## **Свойства**

`-> text` - указывает текст на кнопке.

`-> font` - указывает шрифт на кнопке.

`-> underline` - указывает подчёркивание на тексте.

`-> wrapText` - указывает на авто перенос на тексте.

`-> textAlignment` - указывает выравнивание текста на кнопке.

`-> alignment` - указывает выравнивание текста на кнопке.

`-> graphic` - добавляет иконку рядом с текстом.

`-> graphicTextGap` - добавляет отступ от иконки.

`-> contentDisplay` - центрирование иконки  .

***

## **Пример использования**

<pre class="language-php"><code class="lang-php"><strong># Не забываем подключить use для кнопки, стиля, шрифта, иконки и так далее.
</strong><strong>
</strong><strong>// Создание новой кнопки
</strong>$button = new UXButton("Нажми меня");

// Установка стиля
$style = new UXStyle();
$style->backgroundColor = "lightblue";
$style->textColor = "black";
$button->style = $style;

// Установка шрифта
$button->font = new UXFont("Arial", 16);

// Установка иконки (предполагается, что иконка находится в папке ресурсов проекта)
$button->graphic = new UXImageView(new UXImage("res://icon.png"));

// Установка обработчика события нажатия на кнопку
$button->on("action", function() {
    UXDialog::show("Кнопка нажата!", "Информация");
});

// Установка расположения кнопки на сцене
$button->layoutX = 100;
$button->layoutY = 100;
</code></pre>


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://fxe-documents.gitbook.io/api-docs/komponenty-uxnode/komponenty/knopka.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
