CssBaseline
Set the page background, text color and font from the theme.
CssBaseline gives the page a baseline. It sets the body margin to 0, the body background and text
color from the theme, the body font from the body1 typography variant, and border-box sizing
that every element inherits. Render it once, near the root of your app. It is a Server
Component.
import CssBaseline from '@hone-ui/react/CssBaseline';Example
<ThemeProvider theme={theme}>
<CssBaseline />
<App />
</ThemeProvider>How it works
CssBaseline renders its children plus one hidden marker element. The look CSS styles html and
body only while that marker is in the page (:root:has(.hn-CssBaseline-root)). The rules
ship with the look file you already import, so they apply in server HTML and with JavaScript off.
Without CssBaseline, the page keeps your own body styles. Colors follow light and dark mode
because they come from theme variables.
Props
| Prop | Type | Default | Description |
|---|---|---|---|
enableColorScheme | boolean | false | Restates color-scheme on html for the active mode. |
unlayered | boolean | false | Also writes the page background and color-scheme unlayered. |
nonce | string | For the unlayered style, under a strict CSP. | |
children | ReactNode | Rendered as is. CssBaseline adds no wrapper element around them. |
Notes
- There is no
sx,classNameorref, because no element wraps the children. - Both looks already set
color-schemeonhtml.enableColorSchemematters only if your CSS overrides it. ScopedCssBaselineis not included.