Skip to content

Dynamic color of Starlight SVG logo #2070

Answered by HiDeoo
julien-deramond asked this question in Q&A
Discussion options

You must be logged in to vote

Thanks for the feedback 🙌

Just for reference, this is a bit related to this discussion.

Sharing only as a workaround, you can now use a component override to replace the built-in <SiteTitle> component to inline your SVG (make sure to run it through a website like SVGOMG to optimize it first) and add a CSS rule to change its fill color in dark mode for example.

---
// src/components/SiteTitle.astro
import type { Props } from '@astrojs/starlight/props'

const { siteTitle, siteTitleHref } = Astro.props;
---

<a href={siteTitleHref} class="site-title sl-flex">
  <svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 128 128">
    <g fill="#09090b">
      <path d="..." transform="..."/>
      <path

Replies: 1 comment 1 reply

Comment options

You must be logged in to vote
1 reply
@julien-deramond
Comment options

Answer selected by julien-deramond
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants