Skip to content

feat(nuxt-ui): color mode aware token resolution via data-theme#598

Merged
harlan-zw merged 1 commit into
mainfrom
feat/theme-aware-tokens
May 5, 2026
Merged

feat(nuxt-ui): color mode aware token resolution via data-theme#598
harlan-zw merged 1 commit into
mainfrom
feat/theme-aware-tokens

Conversation

@harlan-zw

Copy link
Copy Markdown
Collaborator

🔗 Linked issue

N/A

❓ Type of change

  • 📖 Documentation
  • 🐞 Bug fix
  • 👌 Enhancement
  • ✨ New feature
  • 🧹 Chore
  • ⚠️ Breaking change

📚 Description

OG components using Tailwind v4 + Nuxt UI semantic tokens (bg-inverted, text-default, border-accented, ...) previously always resolved to dark-mode values, with no way to opt into light mode or per-image theme switching.

This PR adds opt-in theme-aware resolution driven by data-theme on the component root:

  • Static data-theme="light" / data-theme="dark" resolves tokens for that theme at build time.
  • Dynamic :data-theme="colorMode" binding triggers a dual-pass build that emits paired arbitrary classes (e.g. bg-[#fff] dark:bg-[#0a0a0a]); the existing styleDirectives runtime then swaps based on the colorMode prop you pass to defineOgImage.
  • Templates without data-theme keep the existing dark-mode default, so this is fully non-breaking.

Includes docs in the styling guide + color-mode integration page, plus e2e snapshot tests covering static light, static dark, and dynamic-binding paired output.

Adds opt-in theme-aware resolution for Tailwind v4 + Nuxt UI semantic
tokens (bg-inverted, text-default, etc) in OG components. Static
data-theme="light|dark" on the root element resolves tokens for that
theme; a dynamic :data-theme="colorMode" binding emits paired
bg-[#..] dark:bg-[#..] arbitrary classes so the runtime swaps based on
the colorMode prop. Templates without data-theme keep the existing
dark-mode default, so the change is non-breaking.
@pkg-pr-new

pkg-pr-new Bot commented May 5, 2026

Copy link
Copy Markdown

Open in StackBlitz

npm i https://pkg.pr.new/nuxt-og-image@598

commit: aec59fa

@harlan-zw harlan-zw changed the title feat(tw4): theme-aware token resolution via data-theme feat: color mode aware token resolution via data-theme May 5, 2026
@harlan-zw harlan-zw changed the title feat: color mode aware token resolution via data-theme feat(nuxt-ui): color mode aware token resolution via data-theme May 5, 2026
@harlan-zw harlan-zw merged commit 82cec81 into main May 5, 2026
11 checks passed
@harlan-zw harlan-zw deleted the feat/theme-aware-tokens branch May 5, 2026 03:04
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant