diff options
author | HiDeoo | 2024-01-18 18:18:42 +0100 |
---|---|---|
committer | GitHub | 2024-01-18 18:18:42 +0100 |
commit | 773880de87b79bf3107dbc32df29a86dd11e4e6f (patch) | |
tree | db9ca7a32d92ed1b458c0567a57b0af7f2ec6c7c | |
parent | ce01a51da775b968ed7227c81dc87e56bc090cac (diff) | |
download | IT.starlight-773880de87b79bf3107dbc32df29a86dd11e4e6f.tar.gz IT.starlight-773880de87b79bf3107dbc32df29a86dd11e4e6f.tar.bz2 IT.starlight-773880de87b79bf3107dbc32df29a86dd11e4e6f.zip |
Update ToC highlighting styles to prevent UI shifts (#1372)
Co-authored-by: Chris Swithinbank <swithinbank@gmail.com>
-rw-r--r-- | .changeset/young-roses-tickle.md | 17 | ||||
-rw-r--r-- | packages/starlight/components/TableOfContents/TableOfContentsList.astro | 8 |
2 files changed, 19 insertions, 6 deletions
diff --git a/.changeset/young-roses-tickle.md b/.changeset/young-roses-tickle.md new file mode 100644 index 00000000..4a2c2fc8 --- /dev/null +++ b/.changeset/young-roses-tickle.md @@ -0,0 +1,17 @@ +--- +'@astrojs/starlight': minor +--- + +Updates the table of contents highlighting styles to prevent UI shifts when scrolling through a page. + +If you want to preserve the previous, buggy styling, you can add the following custom CSS to your site: + +```css +starlight-toc a[aria-current='true'], +starlight-toc a[aria-current='true']:hover, +starlight-toc a[aria-current='true']:focus { + font-weight: 600; + color: var(--sl-color-text-invert); + background-color: var(--sl-color-text-accent); +} +``` diff --git a/packages/starlight/components/TableOfContents/TableOfContentsList.astro b/packages/starlight/components/TableOfContents/TableOfContentsList.astro index db370b61..8ea9eb84 100644 --- a/packages/starlight/components/TableOfContents/TableOfContentsList.astro +++ b/packages/starlight/components/TableOfContents/TableOfContentsList.astro @@ -38,12 +38,8 @@ const { toc, isMobile = false, depth = 0 } = Astro.props; padding-inline: calc(1rem * var(--depth) + var(--pad-inline)) var(--pad-inline); line-height: 1.25; } - a[aria-current='true'], - a[aria-current='true']:hover, - a[aria-current='true']:focus { - font-weight: 600; - color: var(--sl-color-text-invert); - background-color: var(--sl-color-text-accent); + a[aria-current='true'] { + color: var(--sl-color-text-accent); } .isMobile a { --pad-inline: 1rem; |