---
title: ui-plugin
project: jComponent V19
version: 19.194
section: reference
language: en
license: MIT
url: https://totaljs.es/docs/jcomponent-v19/19-194/reference/ui-plugin/
updated: 2026-11-18T13:58:29.465Z
---

# ui-plugin

> The attributes and configuration keys of the ui-plugin element.

The `<ui-plugin>` element creates a [Scope](../scope/) for its content and connects it to the [Plugin](../plugin/) with the same path. The concept is explained in [Scopes](../../guides/scopes/) and [Plugins](../../guides/plugins/).

## API

### path="path"

Type: `property`

Sets the path of the scope and selects the plugin.

The path of a nested element is appended to the path of its parent scope. The attribute accepts these forms:

| Value | Meaning |
| --- | --- |
| `users` | The scope `users`, or `parent.users` inside another scope. |
| `!users` | An isolated scope. Its path ignores the parent scope. |
| `?` | A scope with a generated unique path. An empty or missing path does the same. |
| `*` | The scope `common`, taken from `DEF.pathcommon`. |
| `users template` | The scope `users` with a new plugin created from `PLUGIN('* template', fn)`. |
| `users__config__default` | The path, configuration and default value in one attribute. |

The plugin of an element without content is removed when the library cleans up unused objects.

Example: Nested scopes
```html
<ui-plugin path="users">
    <ui-plugin path="detail">
        <span></span>
    </ui-plugin>
</ui-plugin>

<script>
    PLUGIN('users', function(exports) {});
    PLUGIN('users.detail', function(exports) {});
    setTimeout(() => console.log($('span').scope().path), 500);  // users.detail
</script>
```

Example: An isolated scope
```html
<ui-plugin path="users">
    <ui-plugin path="!settings">
        <span></span>
    </ui-plugin>
</ui-plugin>

<script>
    PLUGIN('users', function(exports) {});
    PLUGIN('settings', function(exports) {});
    setTimeout(() => console.log($('span').scope().path), 500);  // settings
</script>
```

Example: A reusable plugin template
```html
<ui-plugin path="orders counter"><span></span></ui-plugin>
<ui-plugin path="invoices counter"><span></span></ui-plugin>

<script>
    PLUGIN('* counter', function(exports) {
        console.log(exports.name);
    });
</script>
```

Example: Path, configuration and default value together
```html
<ui-plugin path="users__aclass:1__{ page: 1 }"><span></span></ui-plugin>

<script>
    PLUGIN('users', function(exports) {});
    setTimeout(() => console.log(GET('users.page'), $('ui-plugin').attr('class')), 500);  // 1 users
</script>
```

### config="key:value"

Type: `property`

Configures the scope.

The value is a list of `key:value` pairs. The keys are listed on this page, and all of them are available in [`scope.config`](../scope/#config).

Example: Reading the configuration
```html
<ui-plugin path="users" config="limit:10"><span></span></ui-plugin>

<script>
    PLUGIN('users', function(exports) {});
    setTimeout(() => console.log($('span').scope().config.limit), 500);  // 10
</script>
```

### default="expression"

Type: `property`

Sets the initial value of the scope path.

The attribute contains a JavaScript expression. The [`default()`](../scope/#default) method of the scope restores the value.

Example: An initial model
```html
<ui-plugin path="users" default="{ page: 1 }"><span></span></ui-plugin>

<script>
    PLUGIN('users', function(exports) {});
    setTimeout(() => console.log(GET('users')), 500);  // {"page":1}
</script>
```

### data-jc-value="expression"

Type: `property`

Sets the initial value of the scope path.

It is used when the `default` attribute is missing.

Example: An initial model
```html
<ui-plugin path="users" data-jc-value="{ page: 2 }"><span></span></ui-plugin>

<script>
    PLUGIN('users', function(exports) {});
    setTimeout(() => console.log(GET('users.page')), 500);  // 2
</script>
```

### data-jc-class="classes"

Type: `property`

Toggles CSS classes on the element.

It is used when the `class` configuration key is missing.

Example: A class after the initialization
```html
<ui-plugin path="users" data-jc-class="ready" config="delay:10"><span></span></ui-plugin>
<script>PLUGIN('users', function(exports) {});</script>
```

### data-jc-init="path"

Type: `property`

Calls a function when the scope is created.

It is used when the `init` configuration key is missing. The function has the same arguments as [`init`](#init).

Example: An initialization function
```html
<ui-plugin path="users" data-jc-init="common.onscope"><span></span></ui-plugin>

<script>
    window.common = { onscope: path => console.log(path) };  // users
    PLUGIN('users', function(exports) {});
</script>
```

### isolated:true

Type: `config`

Makes the path of the scope independent of the parent scope.

It has the same effect as the `!` prefix of the path.

Example: An isolated scope
```html
<ui-plugin path="users">
    <ui-plugin path="settings" config="isolated:true"><span></span></ui-plugin>
</ui-plugin>

<script>
    PLUGIN('users', function(exports) {});
    PLUGIN('settings', function(exports) {});
    setTimeout(() => console.log($('span').scope().path), 500);  // settings
</script>
```

### aclass:true

Type: `config`

Adds the path of the scope to the element as a CSS class.

Example: The path as a class
```html
<ui-plugin path="users" config="aclass:true"><span></span></ui-plugin>
<script>PLUGIN('users', function(exports) {});</script>
```

### class:classes

Type: `config`

Toggles CSS classes on the element after a delay.

Separate several classes with a space. The [`delay`](#delay) key sets the delay.

Example: Classes after the delay
```html
<ui-plugin path="users" config="class:ready"><span></span></ui-plugin>
<script>PLUGIN('users', function(exports) {});</script>
```

### delay:milliseconds

Type: `config`

Sets the delay of the `class` key in milliseconds.

The default value is `300`.

Example: A shorter delay
```html
<ui-plugin path="users" config="class:ready;delay:10"><span></span></ui-plugin>

<script>
    PLUGIN('users', function(exports) {});
    setTimeout(() => console.log($('ui-plugin').hclass('ready')), 500);  // true
</script>
```

### init:path

Type: `config`

Calls a function when the scope is created.

The function receives the path and the element of the scope, and `this` is the [Scope](../scope/). A `?` in the value is replaced with the path of the scope.

Example: An initialization function
```html
<ui-plugin path="users" config="init:common.onscope"><span></span></ui-plugin>

<script>
    window.common = {
        onscope: function(path, element) {
            console.log(path, element.prop('tagName'), this.path);  // users UI-PLUGIN users
        }
    };
    PLUGIN('users', function(exports) {});
</script>
```

### plugin="path"

Type: `type`

Other elements can create a scope with an attribute.

Use `plugin`, `data-plugin`, `scope` or `data-scope` on any element. The `<ui-component>`, `<ui-bind>` and `<ui-import>` elements accept only the `plugin` attribute. The value has the same forms as `path`.

Example: A scope on a div
```html
<div plugin="users"><span></span></div>

<script>
    PLUGIN('users', function(exports) {});
    setTimeout(() => console.log($('span').scope().path), 500);  // users
</script>
```
