Theming Based on Priority and State

Apologies if this has been covered before but I did try a search and came up with nothing obvious as an answer…

I would like to colour my items based on the priority value and state. So, an item with @priority(1) would be red, @priority(2) would be orange and anything else with an @priority tag would be green. However if there is also an @done tag then the item is coloured in white (my normal text colour in this theme).

I’m completely new to less so I am hoping that this is really easy!

Many thanks.

I’m not an expert on TaskPaper .less stylesheets, but I don’t think you can use tag values for coloring.

A workaround would be to use a format like @priority1, priority2, etc.

This code:

// Colors @priority1
item[data-priority1] {
  color: rgb(255, 0, 0);

// Colors @priority2
item[data-priority2] {
  color: rgb(255, 128, 0);

// Colors @priority
item[data-priority] {
  color: rgb(0, 175, 0);

Would give you this result:

If you need to use a priority tag with a value, then consider using two tags (one for colors and one for priority).

Example: - High Priority Task @red @priority(1)

1 Like

Thanks Jim. That’s probably the simplest solution and I guess having the tasks coloured is enough.

Interesting that item[data-priority2] is a thing. I’d be playing with item[data-priority="1"]. Your version is much cleaner.

1 Like

To set the style based on a priority value e.g. priority(1) try this style syntax :

// This example colours items tagged with @priority(1) red
item[data-priority=1] {
color: rgb(255, 0, 0);

1 Like