---
url: /reference/items/Action.md
---
# Action
The `Action` component triggers declarative behavior on other components or DOM elements.
## Usage
This component can be directly imported and defined as a dependency of your application and then used directly with `data-...` attributes in your HTML.
In the following example, the buttons each have an `Action` component targeting the [`Transition`](/reference/items/Transition/index.html) component in the page.
:::code-group
```js
import { registerComponent } from '@studiometa/js-toolkit';
import { Action, Transition } from '@studiometa/ui';
registerComponent(Action);
registerComponent(Transition);
```
:::
The `Action` components can control multiple targets:
:::code-group
```js
import { registerComponent } from '@studiometa/js-toolkit';
import { Action, Transition } from '@studiometa/ui';
registerComponent(Action);
registerComponent(Transition);
```
:::
And specify an additional selector to filter the targeted components:
:::code-group
```js
import { registerComponent } from '@studiometa/js-toolkit';
import { Action, Transition } from '@studiometa/ui';
registerComponent(Action);
registerComponent(Transition);
```
:::
### Simple usage with the `Target` component
The `Target` component is a companion of the `Action` component that can be used to easily target other DOM elements without creating specific component.
:::code-group
```js
import { registerComponent } from '@studiometa/js-toolkit';
import { Action, Target } from '@studiometa/ui';
registerComponent(Action);
registerComponent(Target);
```
:::
### Combining it with `Data` components
:::code-group
```js
import { registerComponent } from '@studiometa/js-toolkit';
import { Action, DataBind, DataComputed } from '@studiometa/ui';
registerComponent(Action);
registerComponent(DataBind);
registerComponent(DataComputed);
```
:::
### Listening to multiple events
The advanced HTML [option `on:[.]`](./js-api.md#on-event-modifier) can be used to listen to multiple events on a single `Action` component.
:::code-group
```js
import { registerComponent } from '@studiometa/js-toolkit';
import { Action, Transition } from '@studiometa/ui';
registerComponent(Action);
registerComponent(Transition);
```
:::