# Field dynamic icon

**URL:** https://discuss.tryton.org/t/field-dynamic-icon/5591
**Category:** Developer
**Created:** [October 10, 2022, 1:35pm UTC](https://discuss.tryton.org/t/field-dynamic-icon/5591 "2022-10-10T13:35:31Z")
**Posts on this page:** 3
**Page:** 1

<div class="post-metadata">

### Author: ![pumontjm](https://discuss-cdn.tryton.org/letter_avatar_proxy/v4/letter/p/bbce88/32.png) [@pumontjm](https://discuss.tryton.org/u/pumontjm)
#### Post date: [October 10, 2022, 1:35pm UTC](https://discuss.tryton.org/t/field-dynamic-icon/5591/1 "2022-10-10T13:35:31Z")

</div>

Hello,

I don’t understand how to dynamically assign an icon to a field.

I added an icon on a field,

```xml
<field name="margin_percent" icon="red-chip" symbol="%"/>

```

1. but how to make the icon change according to the value of the field?

value \> 6, icon=green  
value \<= 6 , icon=orange  
value \<= 0, icon=red

1. Is it possible to put the icon after the value instead of in front?

---

<div class="post-metadata">

### Author: ![ced](https://discuss-cdn.tryton.org/user_avatar/discuss.tryton.org/ced/32/1237_2.png) [@ced](https://discuss.tryton.org/u/ced)
#### Post date: [October 10, 2022, 5:22pm UTC](https://discuss.tryton.org/t/field-dynamic-icon/5591/2 "2022-10-10T17:22:58Z")

</div>

> [@pumontjm](#):
>
> but how to make the icon change according to the value of the field?

The content of the attribute `icon` must be the name of a field (but it fall back to a direct icon name if the field does not exist). So this field should contain the name of the icon to display. So usually it is a `Function` fields which a `on_change_with` method as `getter` so it can change the value dynamically.

> [@pumontjm](#):
>
> Is it possible to put the icon after the value instead of in front?

Yes for that you must use a `suffix` tag inside the `field` tag, see [Views — Tryton server](https://docs.tryton.org/projects/server/en/latest/topics/views/index.html#prefix-suffix)

---

<div class="post-metadata">

### Author: ![system](https://discuss-cdn.tryton.org/uploads/default/original/1X/c6f8ec0a40525cdcd50058c734283450a4b3d38b.png) [@system](https://discuss.tryton.org/u/system)
#### Post date: [November 9, 2022, 5:23pm UTC](https://discuss.tryton.org/t/field-dynamic-icon/5591/3 "2022-11-09T17:23:00Z")

</div>

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.
