Skip to content

Add system theme-based favicon (light/dark)#86

Merged
ViktorSvertoka merged 1 commit into
developfrom
feature/favicon
Dec 28, 2025
Merged

Add system theme-based favicon (light/dark)#86
ViktorSvertoka merged 1 commit into
developfrom
feature/favicon

Conversation

@ViktorSvertoka
Copy link
Copy Markdown
Member

@ViktorSvertoka ViktorSvertoka commented Dec 28, 2025

What was done

  • Added separate favicons for light and dark system themes
  • Configured favicon switching via prefers-color-scheme

Implementation details

  • Favicons are stored in the public/ directory
  • Theme switching is handled natively by the browser (no JS involved)
  • Uses Next.js metadata.icons configuration

Result

  • Favicon automatically changes based on system theme
  • Stable behavior across browsers
  • No client-side logic or side effects

Notes

  • Favicon reacts only to system theme (expected browser behavior)
  • App-level theme switching is intentionally not handled

Summary by CodeRabbit

  • New Features
    • Added automatic icon support for light and dark color schemes, adapting to user system preferences.

✏️ Tip: You can customize this high-level summary in your review settings.

@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai Bot commented Dec 28, 2025

📝 Walkthrough

Walkthrough

Adds a new metadata export to the Next.js root layout configuration that defines icon settings for light and dark color schemes. No runtime logic changes—only augments layout metadata through Next.js app directory conventions.

Changes

Cohort / File(s) Summary
Metadata Configuration
frontend/app/layout.tsx
Added export const metadata: Metadata with icon configuration for light and dark color schemes; imported Metadata type from next.

Estimated code review effort

🎯 1 (Trivial) | ⏱️ ~3 minutes

Poem

🐰 A dash of dark, a touch of light,
Icons shimmer, oh what a sight!
Metadata blooms in the layout's home,
No logic changed, just CSS to roam.
✨ Hop hop, the theme now knows! 🌙☀️

Pre-merge checks and finishing touches

✅ Passed checks (3 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title 'Add system theme-based favicon (light/dark)' directly and clearly summarizes the main change: adding favicons that respond to system theme preferences.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
✨ Finishing touches
  • 📝 Generate docstrings
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch feature/favicon

Comment @coderabbitai help to get the list of available commands and usage tips.

@netlify
Copy link
Copy Markdown

netlify Bot commented Dec 28, 2025

Deploy Preview for develop-devlovers ready!

Name Link
🔨 Latest commit 634976a
🔍 Latest deploy log https://app.netlify.com/projects/develop-devlovers/deploys/695197304837b80008219752
😎 Deploy Preview https://deploy-preview-86--develop-devlovers.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify project configuration.

@ViktorSvertoka ViktorSvertoka merged commit d74270f into develop Dec 28, 2025
8 of 9 checks passed
@ViktorSvertoka ViktorSvertoka deleted the feature/favicon branch December 28, 2025 20:49
Copy link
Copy Markdown
Contributor

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 2

🧹 Nitpick comments (1)
frontend/app/layout.tsx (1)

6-17: Consider adding apple-touch-icon for iOS devices.

Including an apple icon entry improves the user experience for iOS users who add the site to their home screen.

🔎 Example implementation
 export const metadata: Metadata = {
   icons: {
     icon: [
       {
         media: '(prefers-color-scheme: light)',
         url: '/favicon-light.svg',
       },
       {
         media: '(prefers-color-scheme: dark)',
         url: '/favicon-dark.svg',
       },
     ],
+    apple: [
+      {
+        url: '/apple-touch-icon.png',
+      },
+    ],
   },
 };
📜 Review details

Configuration used: defaults

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between e5d74b4 and 634976a.

⛔ Files ignored due to path filters (4)
  • frontend/app/favicon.ico is excluded by !**/*.ico
  • frontend/public/favicon-dark.svg is excluded by !**/*.svg
  • frontend/public/favicon-light.svg is excluded by !**/*.svg
  • frontend/public/github-logo.svg is excluded by !**/*.svg
📒 Files selected for processing (1)
  • frontend/app/layout.tsx
🧰 Additional context used
🧬 Code graph analysis (1)
frontend/app/layout.tsx (3)
frontend/app/[locale]/dashboard/page.tsx (1)
  • metadata (11-14)
frontend/app/[locale]/contacts/page.tsx (1)
  • metadata (1-5)
frontend/app/[locale]/not-found.tsx (1)
  • metadata (1-4)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (3)
  • GitHub Check: Redirect rules - develop-devlovers
  • GitHub Check: Header rules - develop-devlovers
  • GitHub Check: Pages changed - develop-devlovers
🔇 Additional comments (1)
frontend/app/layout.tsx (1)

1-1: LGTM!

The type-only import for Metadata is correct and follows Next.js TypeScript conventions.

Comment thread frontend/app/layout.tsx
Comment on lines +5 to +18
export const metadata: Metadata = {
icons: {
icon: [
{
media: '(prefers-color-scheme: light)',
url: '/favicon-light.svg',
},
{
media: '(prefers-color-scheme: dark)',
url: '/favicon-dark.svg',
},
],
},
};
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🟠 Major

Add a fallback icon for broader browser compatibility.

The current configuration only specifies icons with media queries. Browsers that don't support prefers-color-scheme in icon metadata (or older browsers) may fail to display any favicon. Include a default icon entry without a media query as a fallback.

🔎 Proposed fix to add fallback icon
 export const metadata: Metadata = {
   icons: {
     icon: [
+      {
+        url: '/favicon-light.svg',
+      },
       {
         media: '(prefers-color-scheme: light)',
         url: '/favicon-light.svg',
       },
       {
         media: '(prefers-color-scheme: dark)',
         url: '/favicon-dark.svg',
       },
     ],
   },
 };
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
export const metadata: Metadata = {
icons: {
icon: [
{
media: '(prefers-color-scheme: light)',
url: '/favicon-light.svg',
},
{
media: '(prefers-color-scheme: dark)',
url: '/favicon-dark.svg',
},
],
},
};
export const metadata: Metadata = {
icons: {
icon: [
{
url: '/favicon-light.svg',
},
{
media: '(prefers-color-scheme: light)',
url: '/favicon-light.svg',
},
{
media: '(prefers-color-scheme: dark)',
url: '/favicon-dark.svg',
},
],
},
};
🤖 Prompt for AI Agents
In frontend/app/layout.tsx around lines 5 to 18, the metadata.icons only lists
icons with media queries which can result in no favicon in browsers that don't
honor prefers-color-scheme; add a default icon entry (an icon object with url:
'/favicon.ico' or '/favicon-light.svg' and no media) alongside the
media-specific entries so browsers have a fallback and will always display a
favicon.

Comment thread frontend/app/layout.tsx
Comment on lines +9 to +14
media: '(prefers-color-scheme: light)',
url: '/favicon-light.svg',
},
{
media: '(prefers-color-scheme: dark)',
url: '/favicon-dark.svg',
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🔴 Critical

🧩 Analysis chain

🏁 Script executed:

#!/bin/bash
# Check for favicon files in the public directory
fd -t f 'favicon.*\.svg$' public/ 2>/dev/null || echo "No favicon SVG files found"

# Also check the public directory structure
echo "=== Public directory contents ==="
ls -la public/ 2>/dev/null | head -20

Repository: DevLoversTeam/devlovers.net

Length of output: 131


🌐 Web query:

Next.js 16 metadata icons prefers-color-scheme media query support

💡 Result:

Short answer: Yes — Next.js's Metadata API supports a media attribute on icon descriptors so you can provide favicons that use the prefers-color-scheme media query. Example:

export const metadata = {
icons: [
{ rel: 'icon', url: '/favicon-light.png', media: '(prefers-color-scheme: light)' },
{ rel: 'icon', url: '/favicon-dark.png', media: '(prefers-color-scheme: dark)' },
],
};

Notes:

  • This is documented in the Next.js metadata docs showing icon entries with a media field. [1]
  • The Metadata API does not (as of current discussion) support a media attribute for themeColor meta tags — that has been requested in the Next.js repo (issue/discussion). [2]
  • Community guides and examples show this pattern works to load light/dark favicons. [3]

Sources:
[1] Next.js docs — generateMetadata / icons examples.
[2] Vercel/next.js GitHub issue/discussion about media for themeColor.
[3] Community guide on adaptive favicons in Next.js.


Add the missing favicon files to the public/ directory.

The referenced favicon files /favicon-light.svg and /favicon-dark.svg do not exist in public/. The prefers-color-scheme media query approach is supported in Next.js 16, but the implementation will fail at runtime without these files. Create both SVG files in public/ to resolve the broken icon references.

🤖 Prompt for AI Agents
In frontend/app/layout.tsx around lines 9 to 14, the favicon references
'/favicon-light.svg' and '/favicon-dark.svg' are missing from the public/
directory; create two SVG files named favicon-light.svg and favicon-dark.svg in
the project's public/ folder (ensure they are valid SVGs and sized appropriately
for favicons, e.g., include viewBox and simple paths) so the
prefers-color-scheme media entries resolve at runtime and prevent broken icon
references.

liudmylasovetovs pushed a commit that referenced this pull request Jan 9, 2026
Add system theme-based favicon (light/dark)
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