Skip to content

Add $search-highlight-bg SCSS variable for search result highlight color #14148

@cderv

Description

@cderv

Search result highlighting on destination pages (the ?q= parameter feature) uses bare <mark> elements, which inherit Bootstrap's default styling via $mark-bg / --bs-highlight-bg (yellow-100).

Users can already customize this through Bootstrap:

/*-- scss:defaults --*/
$mark-bg: #d1ecf1;

or via CSS:

:root {
  --bs-highlight-bg: #d1ecf1;
}

However, $mark-bg affects all <mark> elements on the page, not just search highlights. It would be useful to have a Quarto-specific SCSS variable like $search-highlight-bg that targets only search result marks, and is documented alongside other SCSS variables at https://quarto.org/docs/output-formats/html-themes.html#sass-variables.

This could be implemented by adding a CSS class to the <mark> elements created in quarto-search.js (line 1138):

const markEl = txt => {
  const el = document.createElement("mark");
  el.appendChild(document.createTextNode(txt));
  return el
}

and styling that class with a dedicated SCSS variable that falls back to $mark-bg.

Context: quarto-dev/quarto-web#1927 (review discussion)

Metadata

Metadata

Assignees

No one assigned

    Labels

    searchthemesRelated to HTML theming or any other style related issue (like highlight-style)

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions