# Add more CSS-classes to buttons (GTK client)

**URL:** <https://discuss.tryton.org/t/add-more-css-classes-to-buttons-gtk-client/1197>\
**Category:** Ideas\
**Created:** [February 27, 2019, 7:09pm UTC](https://discuss.tryton.org/t/add-more-css-classes-to-buttons-gtk-client/1197 "2019-02-27T19:09:35Z")\
**Posts on this page:** 9\
**Page:** 1

<div class="post-metadata">

**Author:** ![edbo](https://discuss-cdn.tryton.org/letter_avatar_proxy/v4/letter/e/f14d63/32.png) [@edbo](https://discuss.tryton.org/u/edbo)\
**Post date:** [February 27, 2019, 7:09pm UTC](https://discuss.tryton.org/t/add-more-css-classes-to-buttons-gtk-client/1197/1 "2019-02-27T19:09:35Z")

</div>

I know, it seems a bit strange 😄 But I’m playing with colors and fonts to give the client a bit more stylish design. I can change a lot by use the gtk inspector. But when I want to change the background color of a button which are used for the workflow (below the forms) all the buttons changes because there are no specific CSS-classes added to the different buttons.

Would it be possible to add a CSS-class to these buttons based on the model (sale, purchase, invoice etc) and the name of the button which is used in the XML-file?  
You will get CSS-classes like `invoice-post` or `invoice-pay` etc. This CSS-classes then can be styled accordingly.

---

<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:** [February 28, 2019, 9:22am UTC](https://discuss.tryton.org/t/add-more-css-classes-to-buttons-gtk-client/1197/2 "2019-02-28T09:22:44Z")

</div>

I find it a little bit random to put method name as class name of a button. This will request to write a lot of CSS rules.  
I think it will be better to look up for common type of buttons and create a class for each type. A type, I can foresee, is button with confirm option.

---

<div class="post-metadata">

**Author:** ![edbo](https://discuss-cdn.tryton.org/letter_avatar_proxy/v4/letter/e/f14d63/32.png) [@edbo](https://discuss.tryton.org/u/edbo)\
**Post date:** [March 2, 2019, 4:48pm UTC](https://discuss.tryton.org/t/add-more-css-classes-to-buttons-gtk-client/1197/3 "2019-03-02T16:48:45Z")

</div>

> [@ced](#):
>
> I find it a little bit random to put method name as class name of a button. This will request to write a lot of CSS rules.

My idea was that adding these classes doesn’t do anything unless you specify them in your `custom.css`. Otherwise the behaviour is the same as it is now. So you don’t have to add extra CSS rules. You can also combine several classes to one rule like `.sale-confirm, .sale-draft, .sale-quote { ... }`

> [@ced](#):
>
> I think it will be better to look up for common type of buttons and create a class for each type. A type, I can foresee, is button with confirm option.

That’s also a possible solution. But does the client know the type of the button? For me it should not add extra data, but reuse the data the button-function gets to create the button.

---

<div class="post-metadata">

**Author:** ![nicoe](https://discuss-cdn.tryton.org/user_avatar/discuss.tryton.org/nicoe/32/2880_2.png) [@nicoe](https://discuss.tryton.org/u/nicoe)\
**Post date:** [March 2, 2019, 4:58pm UTC](https://discuss.tryton.org/t/add-more-css-classes-to-buttons-gtk-client/1197/4 "2019-03-02T16:58:44Z")

</div>

I tend to agree with Cédric here. From my point of view the “Confirm” button on the Sale or on the Purchase should have the same visual style as they have the same purpose (but maybe also a button named differently on another model). So if we want to put some class on it, it would be `.confirm` (or something like that) so that all “Confirmation” buttons would have the same styling throughout the system.

Also I don’t think this is the kind of stuff the client can compute as it’s related to the semantic of the button.

---

<div class="post-metadata">

**Author:** ![edbo](https://discuss-cdn.tryton.org/letter_avatar_proxy/v4/letter/e/f14d63/32.png) [@edbo](https://discuss.tryton.org/u/edbo)\
**Post date:** [March 2, 2019, 5:24pm UTC](https://discuss.tryton.org/t/add-more-css-classes-to-buttons-gtk-client/1197/5 "2019-03-02T17:24:09Z")

</div>

> [@nicoe](#):
>
> I tend to agree with Cédric here. From my point of view the “Confirm” button on the Sale or on the Purchase should have the same visual style as they have the same purpose (but maybe also a button named differently on another model). So if we want to put some class on it, it would be `.confirm` (or something like that) so that all “Confirmation” buttons would have the same styling throughout the system.

We are at the same side here. I totally agree with both of you. It would be nice to change the color of a “confirm” button or a “post” button or whatever and it should be consistent over the whole client. It was just an idea 😄 and no further thoughts if it would be feasible.

> [@nicoe](#):
>
> Also I don’t think this is the kind of stuff the client can compute as it’s related to the semantic of the button.

That’s was my biggest fear which basically means to do something at the server side and it relies on the user to define the right classes.  
Would it be possible to add a new property (e.g. cssclass) to the button definition in the XML? Something like `<button name="cancel" cssclass="btncancel" icon="tryton-cancel"/>`. The client then add the cssclass to the definition. Standard no definition is made in the default CSS file, but the user can use this class to do some styling.

---

<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:** [March 2, 2019, 9:27pm UTC](https://discuss.tryton.org/t/add-more-css-classes-to-buttons-gtk-client/1197/6 "2019-03-02T21:27:01Z")

</div>

> [@edbo](#):
>
> Would it be possible to add a new property (e.g. cssclass) to the button definition in the XML?

For me such class should not be random. We must define a set of different kind of buttons and then apply the corresponding classes.  
As I said previously, I see only confirm and not confirm kind of button for now but maybe someone sees some other kinds.

---

<div class="post-metadata">

**Author:** ![nicoe](https://discuss-cdn.tryton.org/user_avatar/discuss.tryton.org/nicoe/32/2880_2.png) [@nicoe](https://discuss.tryton.org/u/nicoe)\
**Post date:** [March 2, 2019, 10:15pm UTC](https://discuss.tryton.org/t/add-more-css-classes-to-buttons-gtk-client/1197/7 "2019-03-02T22:15:21Z")

</div>

> [@ced](#):
>
> As I said previously, I see only confirm and not confirm kind of button for now but maybe someone sees some other kinds.

Button linked to fresh session RPC calls are also special in some way or else why would they require a fresh session?

---

<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:** [March 2, 2019, 10:24pm UTC](https://discuss.tryton.org/t/add-more-css-classes-to-buttons-gtk-client/1197/8 "2019-03-02T22:24:33Z")

</div>

> [@nicoe](#):
>
> Button linked to fresh session RPC calls are also special in some way or else why would they require a fresh session?

For me, they are particular if we can say before clicking on them that it will request the credentials. But I do not think it is possible to know that.

---

<div class="post-metadata">

**Author:** ![edbo](https://discuss-cdn.tryton.org/letter_avatar_proxy/v4/letter/e/f14d63/32.png) [@edbo](https://discuss.tryton.org/u/edbo)\
**Post date:** [March 5, 2019, 7:25pm UTC](https://discuss.tryton.org/t/add-more-css-classes-to-buttons-gtk-client/1197/9 "2019-03-05T19:25:33Z")

</div>

> [@ced](#):
>
> For me such class should not be random. We must define a set of different kind of buttons and then apply the corresponding classes.

My idea was to make the user responsible (but yeah maybe bad programming practice). If they do nothing, the client uses the desktop-theme just as it is doing now. When they want to customize, they can use the gtk inspector to see the (random) classes.

For now I think we should leave it as is. Maybe in the future this can eventually be picked up. There are other things which needs more attention than this.
