Skip to content

How do I give colors to categories in documents #12635

Answered by mcanouil
haxfn asked this question in Q&A
Discussion options

You must be logged in to vote

You'll have to write that logic yourself somewhere using Lua, Javascript, and (S)CSS:
Don't \`\`\`, simply enclose with more.

Example:

quarto create project blog

add to _quarto.yml

    include-after-body:
      - text: |
          <script>
          document.addEventListener('DOMContentLoaded', function() {
            const categoryDivs = document.querySelectorAll('.listing-category, .quarto-category');
            categoryDivs.forEach(function(div) {
              let content;
              if (div.querySelector('a')) {
                content = div.querySelector('a').textContent.trim().toLowerCase();
              } else {
                content = div.textContent.trim().toLowerCase();

Replies: 2 comments 7 replies

Comment options

You must be logged in to vote
5 replies
@haxfn
Comment options

@mcanouil
Comment options

Answer selected by haxfn
@haxfn
Comment options

@haxfn
Comment options

@mcanouil
Comment options

Comment options

You must be logged in to vote
2 replies
@haxfn
Comment options

@mcanouil
Comment options

mcanouil May 5, 2025
Collaborator

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
themes Related to HTML theming or any other style related issue (like highlight-style)
2 participants