CSS Baseline
Normalize global or scoped typography, box sizing and native color scheme.
This guide covers Material UI Core with the default Emotion engine; extensions and additional demos are explicitly classified.
Use case and business boundary
Global reset and GlobalStyles can affect the whole document; scope selectors carefully during incremental adoption.
Native composition and scope
CssBaseline, ScopedCssBaseline, GlobalStyles
Preserve native Material UI composition and types; do not substitute JGuang UI/Base UI/Radix APIs. Example entries are not extra components.
Native installation and initialization
npm install @mui/material@9.4.0 @emotion/react@11.14.0 @emotion/styled@11.14.1
Use native npm and Emotion, not an invented JGuang UI Registry URL. Place examples inside native ThemeProvider; choose CssBaseline or ScopedCssBaseline for the project. Inspect React, existing providers, lockfile and SSR first. Never overwrite files or conceal peer conflicts. This batch verified React 19.2.8; React 18 and below require matching react-is. See the included bilingual setup guide.
Practical native parameters
These selected parameters are not a flattened universal API. Preserve the native declaring owner, slot structure, nullable values and generics.
| Owner.prop | Practical role | Declaration source |
|---|---|---|
CssBaseline.enableColorScheme | Apply the native color-scheme property for browser controls. | CssBaseline |
ScopedCssBaseline.enableColorScheme | Apply the native color-scheme property for browser controls. | ScopedCssBaseline |
GlobalStyles.styles | Native GlobalStyles rules; scope selectors to avoid cross-system pollution. | GlobalStyles |
Runnable native examples
Machine keys select example entries, not universal variant props. Native demo JSX/data stay unchanged; JGuang-authored acceptance fixtures are explicitly labelled.
- Global reset and native color scheme ·
GlobalBaseline· JGuang-authored native acceptance - Scoped reset without global leakage ·
ScopedBaseline· JGuang-authored native acceptance - GlobalStyles with explicit selectors ·
GlobalCustomization· JGuang-authored native acceptance
Actual usage example
JGuang-authored native acceptance fixture, not an upstream component implementation.
// JGuang-authored example. Native Material UI APIs; not an upstream demo copy.
import CssBaseline from "@mui/material/CssBaseline";
import Paper from "@mui/material/Paper";
import Stack from "@mui/material/Stack";
import Typography from "@mui/material/Typography";
import Button from "@mui/material/Button";
export default function GlobalBaseline() {
return <><CssBaseline enableColorScheme /><Stack spacing={2}><Typography variant="h6">Global CSS baseline / 全局基础样式</Typography><Paper sx={{ p: 3 }}><Typography>Native background, typography and box sizing. 原生背景、排版与盒模型。</Typography><Button variant="contained" sx={{ mt: 2 }}>Continue / 继续</Button><input aria-label="Native date / 原生日期" type="date" defaultValue="2026-01-25" style={{ marginLeft: 16 }} /></Paper></Stack></>;
}
Example dependency boundaries
Native Core/Emotion acceptance fixture.
Direct Icons/System/Utils example imports require their matching 9.4.0 packages. Relative data/helpers are part of the example closure, not extra components. Remote images and simulated operations do not supply a backend.
Pinned upstream API metadata reference
These tables retain the upstream metadata, not a newly inferred generic type system. Conditional generics, inherited props and callback details are defined by the source declarations below. Theme defaults may override metadata defaults.
CssBaseline
import CssBaseline from '@mui/material/CssBaseline';
import { CssBaseline } from '@mui/material';
| Prop | Required | Upstream metadata type / constraint | Metadata default |
|---|---|---|---|
children | no | node | — |
enableColorScheme | no | bool | false |
ScopedCssBaseline
import ScopedCssBaseline from '@mui/material/ScopedCssBaseline';
import { ScopedCssBaseline } from '@mui/material';
| Prop | Required | Upstream metadata type / constraint | Metadata default |
|---|---|---|---|
children | no | node | — |
classes | no | object | — |
component | no | elementType | — |
enableColorScheme | no | bool | — |
sx | no | Array<func | object | bool> | func | object | — |
GlobalStyles
import GlobalStyles from '@mui/material/GlobalStyles';
import { GlobalStyles } from '@mui/material';
| Prop | Required | Upstream metadata type / constraint | Metadata default |
|---|---|---|---|
styles | no | array | func | number | object | string | bool | — |
Native source declarations
Declarations/imports are extracted from pinned source without flattening unions or external inheritance. Original English comments/types are source reference, not a claim of translated upstream prose. Shared types stay in their native packages.
vendor/src/CssBaseline/CssBaseline.d.ts
import * as React from 'react';
import { StyledComponentProps } from '../styles';
export interface CssBaselineProps extends StyledComponentProps<never> {
/**
* You can wrap a node.
*/
children?: React.ReactNode;
/**
* Enable `color-scheme` CSS property to use `theme.palette.mode`.
* For more details, check out https://developer.mozilla.org/en-US/docs/Web/CSS/Reference/Properties/color-scheme
* For browser support, check out https://caniuse.com/?search=color-scheme
* @default false
*/
enableColorScheme?: boolean | undefined;
}
export default function CssBaseline(props: CssBaselineProps): React.JSX.Element;
vendor/src/ScopedCssBaseline/ScopedCssBaseline.d.ts
import * as React from 'react';
import { SxProps } from '@mui/system';
import { Theme } from '../styles';
import { OverridableComponent, OverrideProps } from '../OverridableComponent';
import { ScopedCssBaselineClasses } from './scopedCssBaselineClasses';
export interface ScopedCssBaselineOwnProps {
/**
* The content of the component.
*/
children?: React.ReactNode;
/**
* Override or extend the styles applied to the component.
*/
classes?: Partial<ScopedCssBaselineClasses> | undefined;
/**
* Enable `color-scheme` CSS property to use `theme.palette.mode`.
* For more details, check out https://developer.mozilla.org/en-US/docs/Web/CSS/Reference/Properties/color-scheme
* For browser support, check out https://caniuse.com/?search=color-scheme
*/
enableColorScheme?: boolean | undefined;
/**
* The system prop that allows defining system overrides as well as additional CSS styles.
*/
sx?: SxProps<Theme> | undefined;
}
export interface ScopedCssBaselineTypeMap<
AdditionalProps = {},
RootComponent extends React.ElementType = 'div',
> {
props: AdditionalProps & ScopedCssBaselineOwnProps;
defaultComponent: RootComponent;
}
declare const ScopedCssBaseline: OverridableComponent<ScopedCssBaselineTypeMap>;
export type ScopedCssBaselineProps<
RootComponent extends React.ElementType = ScopedCssBaselineTypeMap['defaultComponent'],
AdditionalProps = {},
> = OverrideProps<ScopedCssBaselineTypeMap<AdditionalProps, RootComponent>, RootComponent> & {
component?: React.ElementType | undefined;
};
vendor/src/GlobalStyles/GlobalStyles.d.ts
import { GlobalStylesProps as StyledGlobalStylesProps } from '@mui/system';
import { Theme } from '../styles';
export interface GlobalStylesProps {
/**
* The styles you want to apply globally.
*/
styles: StyledGlobalStylesProps<Theme>['styles'];
}
export default function GlobalStyles(props: GlobalStylesProps): React.ReactElement<unknown>;
Post-install acceptance
Run strict types, production build and real interactions. Check keyboard labels/focus, disabled/error/read-only semantics where natively supported, both themes, narrow screens and reduced motion. Verify callbacks against the real host data; do not declare installation complete from copying a prompt. Initialization fixtures also require server HTML and warning-free hydration.
Source and license
https://github.com/mui/material-ui/tree/809a7717b4c050ba3f69b75300689f07c050a16e
MIT · @mui/material@9.4.0. Vendor originals and license are preserved. Full original upstream prose remains in vendor/docs and is not represented as fully translated.