Skip to content

Commit 3748254

Browse files
feat(example): add dynamic favicon based on color scheme via useMediaQuery hook
1 parent 11af86a commit 3748254

4 files changed

Lines changed: 15 additions & 0 deletions

File tree

examples/form/components/DefaultLayout.jsx

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,12 @@
11
import { Box, GoToTopButton } from '@barso/ui';
22

3+
import { DefaultHead } from './Head.jsx';
34
import { Header } from './Header.jsx';
45

56
export function DefaultLayout({ children, containerWidth }) {
67
return (
78
<>
9+
<DefaultHead />
810
<Header />
911
<Box
1012
sx={{

examples/form/components/Head.jsx

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
'use client';
2+
import { useMediaQuery } from '@barso/hooks';
3+
import Head from 'next/head';
4+
5+
export function DefaultHead() {
6+
const isDark = useMediaQuery('(prefers-color-scheme: dark)');
7+
8+
return (
9+
<Head>
10+
<link rel="icon" href={isDark ? '/favicon-dark.png' : '/favicon-light.png'} key="favicon" />
11+
</Head>
12+
);
13+
}
6.46 KB
Loading
6.24 KB
Loading

0 commit comments

Comments
 (0)