---
url: https://docs.cybrosys.com/vs-code-extension/features/owl-components.md
description: >-
  Create OWL components, field widgets, public components and services in an
  Odoo module and register them in the manifest assets.
---

# OWL components

Create an OWL component, field widget, public component or service in the current module. The extension adds the files to the manifest `assets` for you and writes a working example in each.

## What you can do

| Component | Created in | Bundle |
|---|---|---|
| **Common Component** | `static/src/components/<name>/` (`.js`, `.xml`, `.css`) | `web.assets_backend` |
| **Field Widget Component** | `static/src/views/fields/<name>/` (`.js`, `.xml`, `.scss`) | `web.assets_backend` |
| **Public Component** | `static/src/components/<name>/` (`.js`, `.xml`, `.scss`), registered in `public_components` | `web.assets_frontend` on Odoo 20, `web.assets_backend` on 18 and 19 |
| **Owl Service** | `static/src/services/<name>/<name>.js` | `web.assets_backend` |

Odoo 20 components use OWL 3. Odoo 18 and 19 use OWL 2, with the `/** @odoo-module **/` header and `useState`. The extension also adds `base` to the manifest `depends` if it is missing.

## Get started

1. Right-click a folder in your module in the Explorer.
2. Select **Assista Odoo** > **Create OWL Components**, then choose the component type.
3. Enter a component name and press **Enter**.

The command works only inside an Odoo module. If a folder with the component's name already exists, the extension shows an error and creates nothing.

### How names are formed

The extension removes every character that is not a letter, `_` or a space. It turns spaces into `_` and lowercases the result to get the folder and file name. The class name is that name in CamelCase.

| You enter | Folder and files | Class |
|---|---|---|
| `My Widget` | `my_widget` | `MyWidget` |
| `MyWidget` | `mywidget` | `Mywidget` |

Digits are dropped, so `Chart2` becomes `chart`. Separate words with spaces or underscores to get a CamelCase class name.

## What each type contains

### Common Component

A reusable component with a counter, a text input and a loading state. Use it in another component's template, after you add it to that component's `static components`.

```xml
<MyWidget title="'Hello'"/>
```

The template is named `<module>.<ClassName>`, and the class sits in `static/src/components/my_widget/my_widget.js`.

### Field Widget Component

A widget for `Char` fields. It shows the value in read-only mode and an input in edit mode. It is registered in the `fields` registry under the folder name. Use it in a view with `widget`:

```xml
<field name="name" widget="my_widget"/>
```

Change `supportedTypes` in the generated file to use it on other field types.

### Public Component

A website and portal component that has a child component showing a labelled value. It is registered in the `public_components` registry. On Odoo 20, the registry key is `<module>.<ClassName>`, and you place it in a QWeb page with:

```xml
<owl-component name="my_module.MyWidget" t-att-props="json.dumps({'title': 'Hello'})"/>
```

On Odoo 18 and 19, the key is the component's folder name.

### Owl Service

A service that depends on `orm`, keeps a private counter and exposes a small API. It is registered in the `services` registry under the folder name. Use it in a component:

```js
this.myService = useService("my_service");
```

## Tips and limits

* Field widgets and public components appear in [smart suggestions](/vs-code-extension/features/smart-suggestions) and [Go to Definition](/vs-code-extension/features/odoo-go-to-definition) once the index includes them.
* Check the Odoo version in the status bar first. The generated JavaScript differs between OWL 2 and OWL 3.
* To scaffold a whole module around an OWL client action, see [Module templates](/vs-code-extension/features/module-templates).

## Next steps

* [Extend POS screens](/vs-code-extension/features/pos-extension)
* [Odoo OWL documentation](https://www.odoo.com/documentation/master/developer/reference/frontend/owl_components.html)
