> For the complete documentation index, see [llms.txt](https://docs.appmixer.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.appmixer.com/6.0/5.1/appmixer-sdk/ui-and-widgets.md).

# UI & Widgets

Appmixer UI is a tool for building user interfaces with component-based widgets.

## Configuration <a href="#configuration" id="configuration"></a>

Widgets are included in `appmixer.ui` instances made with **Appmixer** constructor:

```javascript
const appmixer = new Appmixer(/* ... */)
const widget = appmixer.ui.FlowManager(config)
```

#### `config.el` <a href="#config-el" id="config-el"></a>

Type: `String|Element` | Default: `null`

HTML DOM element to serve as a container of the widget.

#### `config.theme` <a href="#config-theme" id="config-theme"></a>

Type: `Object` | Default: `DefaultTheme`

Custom theme definition.

#### `config.l10n` <a href="#config-l10n" id="config-l10n"></a>

Type: `Object` | Default: `DefaultL10N`

Custom localization texts.

#### `config.lang` <a href="#config-lang" id="config-lang"></a>

Type: `String` | Default: `en`

Language code for localization of components.

#### `config.api` <a href="#config-api" id="config-api"></a>

Type: `Object` | Default: `DefaultAPI`

Custom API methods.

## Instance <a href="#instance" id="instance"></a>

#### `widget.open` <a href="#widget-open" id="widget-open"></a>

```javascript
widget.open()
```

Mount the `widget` instance and render it inside the `el` container.

#### `widget.close` <a href="#widget-close" id="widget-close"></a>

```javascript
widget.close()
```

Unmount the `widget` instance and hide the `el` container.

#### `widget.reload` <a href="#widget-reload" id="widget-reload"></a>

```javascript
widget.reload()
```

Reload the entire `widget`.

#### `widget.reset` <a href="#widget-reset" id="widget-reset"></a>

```javascript
widget.reset()
```

Reset the state of the widget to defaults.

#### `widget.state` <a href="#widget-state" id="widget-state"></a>

Use `state` for properties that may change at any time when the `widget` is active.

```javascript
widget.state(path, value) // setter
widget.state(path) // getter
```

<details>

<summary>Example</summary>

```json
{
  "foo": false,
  "bar": { "counter": 1 }
}
```

```javascript
// set properties by key or path
widget.state('foo', true)
widget.state('bar', { counter: 2 })
widget.state('bar/counter', 3)

// get properties by key or path
widget.state('foo') // true
widget.state('bar') // { counter: 3 }
widget.state('bar/counter') // 3

// get the entire state
widget.state() // { foo: true, bar: { counter: 3 } }

// reset the state to defaults
widget.reset() // { foo: false, bar: { counter: 1 } }
```

</details>

#### `widget.set` <a href="#widget-set" id="widget-set"></a>

```javascript
widget.set(key, value)
```

Set `config` property.

#### `widget.get` <a href="#widget-get" id="widget-get"></a>

```javascript
widget.get(key, value)
```

Get `config` property.

#### `widget.on` <a href="#widget-on" id="widget-on"></a>

```javascript
widget.on(name, handler)
```

Add a new event listener and disable the default handler of the event.

#### `widget.off` <a href="#widget-off" id="widget-off"></a>

```javascript
widget.off(name)
```

Remove an event listener and enable the default handler of the event.


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## 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 following URL with the `ask` and `goal` query parameters:

```
GET https://docs.appmixer.com/6.0/5.1/appmixer-sdk/ui-and-widgets.md?ask=<question>&goal=<user_goal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is what the user is ultimately trying to achieve, the reason they need the answer. Sharing it helps GitBook give you a better, more relevant answer. A goal is most helpful when it describes the outcome the user wants rather than restating the question. For example, with `ask=how do I create an API token`, a goal like `build a script that syncs our docs to a CMS` lets GitBook tailor the answer to that use case.

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.
