# Button

(part of package '[Bootstrap Components](/reference/servoyextensions/packages/ui-component-packages/bootstrap-components.md)')\
Extends designtime/SolutionModel: [JSWebComponent](/reference/servoycore/dev-api/solutionmodel/jswebcomponent.md)\
Extends runtime: [RuntimeWebComponent](/reference/servoycore/dev-api/forms/runtimeform/elements/runtimewebcomponent.md)

A simple button. It can contain text as well as (optionally) an icon before or after the text.

This is a reference page; many components have detailed usage guides [here](https://docs.servoy.com/guides/develop/application-design/ui-components).

## Properties

### enabled

Whether the component is enabled or not; blocks onAction, onDoubleClick, onRightClick events. Type: [Enabled](/reference/servoy-developer/component_and_service_property_types.md#protected) Default Value: true

***

### imageStyleClass

For buttons showing as plain text, you can also specify an image styleclass to be displayed to the left. Can be font awesome icons. Type: [Styleclass](/reference/servoy-developer/component_and_service_property_types.md#styleclass)

***

### showAs

Option whether button text is shown as plain text, sanitized html or trusted html (as is). Type: [String](/reference/servoycore/dev-api/js-lib/string.md)

***

### styleClass

Button style class, typically one of the bootstrap button classes (e.g. 'btn btn-primary') Type: [Styleclass](/reference/servoy-developer/component_and_service_property_types.md#styleclass) Default Value: "btn btn-default"

***

### tabSeq

Tab sequence index of the form Type: [Tabseq](/reference/servoy-developer/component_and_service_property_types.md#tabseq)

***

### text

The text shown for the button (i18n is supported) Type: [Tagstring](/reference/servoy-developer/component_and_service_property_types.md#tagstring)

***

### toolTipText

Tooltip text shown when hovering over the button (i18n is supported) Type: [Tagstring](/reference/servoy-developer/component_and_service_property_types.md#tagstring)

***

### trailingImageStyleClass

An icon style class property (glyphicon, material design or Font Awesome).\
Example 'fas fa-search'\
If you want to use Font Awesome classes you need to enable the Font Awesome service from the Servoy Package Manager. Type: [String](/reference/servoycore/dev-api/js-lib/string.md)

***

### variant

Sets the variant of this button, this sets a certain set of styleclasses at runtime for which this variant is configured for Type: [Variant](/reference/servoy-developer/component_and_service_property_types.md#variant)

***

### visible

Whether the button is visible or not Type: [Visible](/reference/servoy-developer/component_and_service_property_types.md#visible)

***

## Events

### onActionMethodID(event)

Fired when the button is clicked

**Parameters:**

> * {[JSEvent](/reference/servoycore/dev-api/application/jsevent.md)} event The event object containing details about the click event (e.g., target element, mouse coordinates).

***

### onDoubleClickMethodID(event)

Fired when the button is double clicked

**Parameters:**

> * {[JSEvent](/reference/servoycore/dev-api/application/jsevent.md)} event \* @param {JSEvent} event The event object containing details about the double-click event (e.g., target element, click timing).

***

### onRightClickMethodID(event)

Fired when the button is right clicked

**Parameters:**

> * {[JSEvent](/reference/servoycore/dev-api/application/jsevent.md)} event The event object containing details about the right-click event (e.g., target element, context menu trigger).

***

## API

### requestFocus()

Set the focus to this button.

**Example:**

```js
myElement.requestFocus();
```

***

***


---

# 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://docs.servoy.com/reference/servoyextensions/ui-components/buttons-and-text/button.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.
