Problem: I wanted to format canceled tasks differently than regular completed tasks. I’m defining a “canceled” task as one where there is a dash in the brackets instead of an x. I would like canceled tasks to have a grey checkmark, and have grey (but not strikethrough) text.
Example:
Solution: To accomplish this, I took advantage of the fact that Obsidian records which character was used to check a task in the data-task attribute of the <li> item:
So this CSS does the trick:
/* ==================================================================== */
/* CHECKLISTS */
/* ==================================================================== */
/* Special handling for canceled tasks, e.g.
* - [x] This is done
* - [-] This was canceled
* - [ ] Needs doing
*/
/* Make canceled item text gray but not struck out. */
ul > li.task-list-item[data-task="-"] {
color: var(--text-faint);
}
/* Make canceled checkbox light gray */
ul > li.task-list-item[data-task="-"] > input {
filter: grayscale(100%) opacity(25%);
}
I just did this yesterday, with the default theme.
I poked around in the Web Inspector and noticed that it does the regular checkboxes with SVGs in CSS masks, so you can “just” swap out that mask, and optionally also change colours: