Skip to content

Tag

Available for fields of type selection, many2one, char and boolean and can be used in form and tree views. It is a tag that can be used to show a label with a color.

<field name="status" widget="tag" />

Assigning colors

In this case we can use the widget_props to assign a color to a specific value.

  • We have to use the parameter colors with the value as a dictionary with the value as the key and the color as the value.
  • We can use colorField to get the color from a field in the record.
    v2.55.0

Base palette

We can use the default colors from ant design: blue, green, red, orange, cyan, geekblue, purple, magenta, volcano, gold, lime, yellow, amber, orange, red, magenta, purple, geekblue, cyan, blue, green, grey, default.

<field name="status" widget="tag"
widget_props="{'colors': {'warning_step1': 'orange'}}" />

Using state based colors

We can use the state based colors from ant design: success, processing, error, default, warning.

<field name="state" widget="tag"
widget_props="{'colors': {'draft': 'default', 'cancel': 'error', 'open': 'processing', 'done': 'success', 'pending': 'warning'}}"
/>

Getting the color automatically

We can use the colors parameter with the value auto to get the color automatically based on the value.

<field name="state" widget="tag"
widget_props="{'colors': 'auto'}"
/>

Using with boolean fields

When using in boolean fields, the colors are success for true and error for false by default.

If you want to change the colors, you can use the colors parameter with the value as a dictionary with the value as the key and the color as the value.

<field name="active" widget="tag"
widget_props="{'colors': {'true': 'blue', 'false': 'magenta'}}" />

The content of the tag will be the label of the field capitalized and when the value is false it will be prefixed with Not. You can customize the content using the string attribute in the <field> tag.

<field name="is_connected" widget="tag" string="Connected" />

API

PropertyDescriptionTypeDefaultVersion
widget_propsObject with the following propertiesobject--

Widget Props

PropertyDescriptionTypeDefaultVersion
colorsDictionary with the value as the key and the color as the value. See Assigning colorsobject | string--
colorFieldField name to get the color from. See Assigning colorsstring- v2.55.0