사전 환경 및 구현 목표:
- 프로젝트 내부에서 라이트/다크 모드 구분 없이 단일 모드(라이트 모드) 사용
- 시스템 설정에 따라 브라우저가 라이트 또는 다크 모드로 변경됨에 따라 파비콘 이미지가 동적으로 변경될 수 있도록 하고자 함
// app/layout.tsx
export const metadata: Metadata = {
title: "Your application's title",
description:
"Your application's description",
icons: {
icon: [
{
media: "(prefers-color-scheme: light)",
url: "/images/favicon-light.png",
type: "image/png",
},
{
media: "(prefers-color-scheme: dark)",
url: "/images/favicon-dark.png",
type: "image/png",
},
],
},
};
파비콘 png 파일 경로는 다음과 같이 배치
📚 참고자료
How to Dynamically Change Favicon for Dark and Light Mode in Next.js 14 or 15?
I am working on a Next.js 14 application using App Router and I'd like to dynamically change the favicon based on the user's color scheme preference (dark or light mode). Currently, I have a black-
stackoverflow.com
'배워서 남 주자' 카테고리의 다른 글
SLASH 21 - 실무에서 바로 쓰는 Frontend Clean Code (1) | 2025.02.11 |
---|---|
feature flags를 도입하기까지 (0) | 2024.12.31 |
볼드, 이탤릭 등 스타일 변경 기능 구현 (2) (0) | 2024.10.27 |
볼드, 이탤릭 등 스타일 변경 기능 구현 (1) (0) | 2024.10.20 |
PR에 빌드 에러 발생시 github-actions bot이 자동으로 코멘트 달게 하기 (0) | 2024.10.03 |