TanStack / TanStack/router

Set multiple 'theme-color' in head

Open
#5,146 2 comments 5 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

start-head
Dominant language
TypeScript
Stars
15.1k
Forks
1.9k
Avg merge
1d 20h
Merged PRs (30d)
143

Description

Which project does this relate to?

Router

Describe the bug

Following the doc of MDN : https://developer.mozilla.org/en-US/docs/Web/HTML/Reference/Elements/meta/name/theme-color

I would like to add 2 meta tags with the same name.

<meta
  name="theme-color"
  content="cornflowerblue"
  media="(prefers-color-scheme: light)" />
<meta
  name="theme-color"
  content="dimgray"
  media="(prefers-color-scheme: dark)" />

But TanStack router says : "meta tags with the same name or property will be overridden by the last occurrence of that tag found in nested routes"
Src : https://tanstack.com/router/v1/docs/framework/react/guide/document-head-management

So how to handle my use case ?

Your Example Website or App

https://codesandbox.io/p/devbox/pedantic-poitras-7hrmrd?workspaceId=ws_VUPqXCcptK4abDwy6H7mEq

Steps to Reproduce the Bug or Issue
  1. Go to https://codesandbox.io/p/devbox/pedantic-poitras-7hrmrd?workspaceId=ws_VUPqXCcptK4abDwy6H7mEq
  2. Check head tag
  3. Check that there is only 1 "theme-color" tag instead of 2.
Expected behavior

As a user, I expect to see 2 theme color meta tags

Screenshots or Videos

No response

Platform
  • Router / Start Version: Last version
Additional context

No response

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with the linked CodeSandbox reproduction and the document-head-management guide, then trace how nested route meta tags are deduplicated. Done means the router preserves both theme-color meta tags when their media attributes differ, with coverage for the reported light and dark scheme case.

Written by the indexing model from the issue text.

Assessment

Tech stack
react, typescript
Domain
frontend
Issue type
Feature
Difficulty
4/5
Estimated time
3-5 days
Activity status
Quiet
Clarity
Mostly clear
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.