|
| 1 | +import { ScrollViewStyleReset } from 'expo-router/html'; |
| 2 | + |
| 3 | +// This file is web-only and used to configure the root HTML for every |
| 4 | +// web page during static rendering. |
| 5 | +// The contents of this function only run in Node.js environments and |
| 6 | +// do not have access to the DOM or browser APIs. |
| 7 | +export default function Root({ children }: { children: React.ReactNode }) { |
| 8 | + return ( |
| 9 | + <html lang="en"> |
| 10 | + <head> |
| 11 | + <meta charSet="utf-8" /> |
| 12 | + <meta httpEquiv="X-UA-Compatible" content="IE=edge" /> |
| 13 | + |
| 14 | + {/* |
| 15 | + This viewport disables scaling which makes the mobile website act more like a native app. |
| 16 | + However this does reduce built-in accessibility. If you want to enable scaling, use this instead: |
| 17 | + <meta name="viewport" content="width=device-width, initial-scale=1.0, viewport-fit=cover" /> |
| 18 | + */} |
| 19 | + <meta |
| 20 | + name="viewport" |
| 21 | + content="width=device-width,initial-scale=1,minimum-scale=1,maximum-scale=1.00001,viewport-fit=cover" |
| 22 | + /> |
| 23 | + {/* |
| 24 | + Disable body scrolling on web. This makes ScrollView components work closer to how they do on native. |
| 25 | + However, body scrolling is often nice to have for mobile web. If you want to enable it, remove this line. |
| 26 | + */} |
| 27 | + <ScrollViewStyleReset /> |
| 28 | + |
| 29 | + {/* Using raw CSS styles as an escape-hatch to ensure the background color never flickers in dark-mode. */} |
| 30 | + <style dangerouslySetInnerHTML={{ __html: responsiveBackground }} /> |
| 31 | + {/* Add any additional <head> elements that you want globally available on web... */} |
| 32 | + </head> |
| 33 | + <body>{children}</body> |
| 34 | + </html> |
| 35 | + ); |
| 36 | +} |
| 37 | + |
| 38 | +const responsiveBackground = ` |
| 39 | +body { |
| 40 | + background-color: #fff; |
| 41 | +} |
| 42 | +@media (prefers-color-scheme: dark) { |
| 43 | + body { |
| 44 | + background-color: #000; |
| 45 | + } |
| 46 | +}`; |
0 commit comments