Last active
July 3, 2025 16:03
-
-
Save ScriptDevil/01db841699172cb124f2cf585f699f16 to your computer and use it in GitHub Desktop.
Custom checkboxes for Obsidian
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| /* | |
| * | |
| * save to .obsidian/snippets/checkboxes.css | |
| * I use the following states | |
| * | |
| * | |
| * TODO ( ) => | |
| * WIP (/) | DELEGATED (>) | BLOCKED/PAUSED (.) => | |
| * CANCELLED (-) | DONE (x) | |
| * | |
| * --- | |
| * Default transition rules defined in Obsidian Tasks | |
| * These define the next state on a click | |
| * | |
| * => Core statuses section <= | |
| * TODO => WIP | |
| * | |
| * => Custom statuses section <= | |
| * WIP => DONE | |
| * CANCELLED => TODO | |
| * BLOCKED => WIP | |
| * DELEGATED => DONE | |
| */ | |
| /* | |
| * For each of the checked types, you need to set some properties in common: | |
| */ | |
| input[data-task="x"]:checked, li[data-task="x"] > input:checked, li[data-task="x"] > p > input:checked | |
| input[data-task="/"]:checked, li[data-task="/"] > input:checked, li[data-task="/"] > p > input:checked | |
| input[data-task=">"]:checked, li[data-task=">"] > input:checked, li[data-task=">"] > p > input:checked | |
| input[data-task="-"]:checked, li[data-task="-"] > input:checked, li[data-task="-"] > p > input:checked | |
| input[data-task="."]:checked, li[data-task="."] > input:checked, li[data-task="."] > p > input:checked | |
| { | |
| --checkbox-marker-color: transparent; | |
| border: none; | |
| border-radius: 0; | |
| background-image: none; | |
| background-color: currentColor; | |
| -webkit-mask-size: var(--checkbox-icon); | |
| color: var(--text-accent); | |
| } | |
| /* | |
| * | |
| * Icon names listed below come from https://remixicon.com | |
| */ | |
| /* [ ] TODO -> checkbox-blank-circle | |
| input[data-task=" "]:not(:checked), li[data-task=" "] > input:not(:checked), li[data-task=" "] > p > input:not(:checked) { | |
| -webkit-mask-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='currentColor'%3E%3Cpath d='M12 22C6.47715 22 2 17.5228 2 12C2 6.47715 6.47715 2 12 2C17.5228 2 22 6.47715 22 12C22 17.5228 17.5228 22 12 22ZM12 20C16.4183 20 20 16.4183 20 12C20 7.58172 16.4183 4 12 4C7.58172 4 4 7.58172 4 12C4 16.4183 7.58172 20 12 20Z'%3E%3C/path%3E%3C/svg%3E"); | |
| } | |
| /* [x] DONE -> check-double; text strikethrough by default */ | |
| input[data-task="x"]:checked, li[data-task="x"] > input:checked, li[data-task="x"] > p > input:checked { | |
| -webkit-mask-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='currentColor'%3E%3Cpath d='M11.602 13.7599L13.014 15.1719L21.4795 6.7063L22.8938 8.12051L13.014 18.0003L6.65 11.6363L8.06421 10.2221L10.189 12.3469L11.6025 13.7594L11.602 13.7599ZM11.6037 10.9322L16.5563 5.97949L17.9666 7.38977L13.014 12.3424L11.6037 10.9322ZM8.77698 16.5873L7.36396 18.0003L1 11.6363L2.41421 10.2221L3.82723 11.6352L3.82604 11.6363L8.77698 16.5873Z'%3E%3C/path%3E%3C/svg%3E"); | |
| } | |
| /* [/] WIP -> focus-2 */ | |
| input[data-task="/"]:checked, li[data-task="/"] > input:checked, li[data-task="/"] > p > input:checked { | |
| -webkit-mask-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='currentColor'%3E%3Cpath d='M12 20C16.4183 20 20 16.4183 20 12C20 7.58172 16.4183 4 12 4C7.58172 4 4 7.58172 4 12C4 16.4183 7.58172 20 12 20ZM12 22C6.47715 22 2 17.5228 2 12C2 6.47715 6.47715 2 12 2C17.5228 2 22 6.47715 22 12C22 17.5228 17.5228 22 12 22ZM12 16C14.2091 16 16 14.2091 16 12C16 9.79086 14.2091 8 12 8C9.79086 8 8 9.79086 8 12C8 14.2091 9.79086 16 12 16ZM12 18C8.68629 18 6 15.3137 6 12C6 8.68629 8.68629 6 12 6C15.3137 6 18 8.68629 18 12C18 15.3137 15.3137 18 12 18ZM12 14C10.8954 14 10 13.1046 10 12C10 10.8954 10.8954 10 12 10C13.1046 10 14 10.8954 14 12C14 13.1046 13.1046 14 12 14Z'%3E%3C/path%3E%3C/svg%3E"); | |
| } | |
| /* [/] WIP text => bold + accent color text */ | |
| body:not(.tasks) .markdown-source-view.mod-cm6 .HyperMD-task-line[data-task]:is([data-task="/"]), | |
| body:not(.tasks) .markdown-preview-view ul li[data-task="/"].task-list-item.is-checked, | |
| body:not(.tasks) li[data-task="/"].task-list-item.is-checked { | |
| color: var(--text-accent); | |
| font-weight: 700; | |
| } | |
| /* [>] Delegated -> user-add*/ | |
| input[data-task=">"]:checked, li[data-task=">"] > input:checked, li[data-task=">"] > p > input:checked { | |
| -webkit-mask-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='currentColor'%3E%3Cpath d='M14 14.252V16.3414C13.3744 16.1203 12.7013 16 12 16C8.68629 16 6 18.6863 6 22H4C4 17.5817 7.58172 14 12 14C12.6906 14 13.3608 14.0875 14 14.252ZM12 13C8.685 13 6 10.315 6 7C6 3.685 8.685 1 12 1C15.315 1 18 3.685 18 7C18 10.315 15.315 13 12 13ZM12 11C14.21 11 16 9.21 16 7C16 4.79 14.21 3 12 3C9.79 3 8 4.79 8 7C8 9.21 9.79 11 12 11ZM18 17V14H20V17H23V19H20V22H18V19H15V17H18Z'%3E%3C/path%3E%3C/svg%3E"); | |
| } | |
| /* [-] Canceled -> delete-bin + faded */ | |
| input[data-task="-"]:checked, li[data-task="-"] > input:checked, li[data-task="-"] > p > input:checked { | |
| color: var(--text-faint); | |
| -webkit-mask-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='currentColor'%3E%3Cpath d='M17 6H22V8H20V21C20 21.5523 19.5523 22 19 22H5C4.44772 22 4 21.5523 4 21V8H2V6H7V3C7 2.44772 7.44772 2 8 2H16C16.5523 2 17 2.44772 17 3V6ZM18 8H6V20H18V8ZM9 11H11V17H9V11ZM13 11H15V17H13V11ZM9 4V6H15V4H9Z'%3E%3C/path%3E%3C/svg%3E"); | |
| } | |
| /* [-] Canceled text -> striketrhough + faded */ | |
| body:not(.tasks) .markdown-source-view.mod-cm6 .HyperMD-task-line[data-task]:is([data-task="-"]), | |
| body:not(.tasks) .markdown-preview-view ul li[data-task="-"].task-list-item.is-checked, | |
| body:not(.tasks) li[data-task="-"].task-list-item.is-checked { | |
| color: var(--text-faint); | |
| text-decoration: line-through solid var(--text-faint) 1px; | |
| } | |
| /* [.] Blocked -> loader-2 */ | |
| input[data-task="."]:checked, li[data-task="."] > input:checked, li[data-task="."] > p > input:checked { | |
| -webkit-mask-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='currentColor'%3E%3Cpath d='M12 2C12.5523 2 13 2.44772 13 3V6C13 6.55228 12.5523 7 12 7C11.4477 7 11 6.55228 11 6V3C11 2.44772 11.4477 2 12 2ZM12 17C12.5523 17 13 17.4477 13 18V21C13 21.5523 12.5523 22 12 22C11.4477 22 11 21.5523 11 21V18C11 17.4477 11.4477 17 12 17ZM22 12C22 12.5523 21.5523 13 21 13H18C17.4477 13 17 12.5523 17 12C17 11.4477 17.4477 11 18 11H21C21.5523 11 22 11.4477 22 12ZM7 12C7 12.5523 6.55228 13 6 13H3C2.44772 13 2 12.5523 2 12C2 11.4477 2.44772 11 3 11H6C6.55228 11 7 11.4477 7 12ZM19.0711 19.0711C18.6805 19.4616 18.0474 19.4616 17.6569 19.0711L15.5355 16.9497C15.145 16.5592 15.145 15.9261 15.5355 15.5355C15.9261 15.145 16.5592 15.145 16.9497 15.5355L19.0711 17.6569C19.4616 18.0474 19.4616 18.6805 19.0711 19.0711ZM8.46447 8.46447C8.07394 8.85499 7.44078 8.85499 7.05025 8.46447L4.92893 6.34315C4.53841 5.95262 4.53841 5.31946 4.92893 4.92893C5.31946 4.53841 5.95262 4.53841 6.34315 4.92893L8.46447 7.05025C8.85499 7.44078 8.85499 8.07394 8.46447 8.46447ZM4.92893 19.0711C4.53841 18.6805 4.53841 18.0474 4.92893 17.6569L7.05025 15.5355C7.44078 15.145 8.07394 15.145 8.46447 15.5355C8.85499 15.9261 8.85499 16.5592 8.46447 16.9497L6.34315 19.0711C5.95262 19.4616 5.31946 19.4616 4.92893 19.0711ZM15.5355 8.46447C15.145 8.07394 15.145 7.44078 15.5355 7.05025L17.6569 4.92893C18.0474 4.53841 18.6805 4.53841 19.0711 4.92893C19.4616 5.31946 19.4616 5.95262 19.0711 6.34315L16.9497 8.46447C16.5592 8.85499 15.9261 8.85499 15.5355 8.46447Z'%3E%3C/path%3E%3C/svg%3E"); | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment