Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
28 commits
Select commit Hold shift + click to select a range
1464097
[material-ui] Corrected generic type definition in `SelectChangeEvent…
SuyashShukla0007 Apr 18, 2025
c5d8614
[blog] Fix migration link on v8 announcement (#45945)
joserodolfofreitas Apr 18, 2025
f23cb88
[core] Fix outdated <link rel="shortcut icon" (#45916)
oliviertassinari Apr 18, 2025
51849e6
[blog] Add more content to 'Material UI v7 is here' (#45905)
oliviertassinari Apr 18, 2025
9e8a6a8
Bump @next/eslint-plugin-next to ^15.3.1 (#45951)
renovate[bot] Apr 20, 2025
7358dff
Bump @tailwindcss/postcss to ^4.1.4 (#45952)
renovate[bot] Apr 20, 2025
412ccce
Bump flexsearch to ^0.8.158 (#45954)
renovate[bot] Apr 20, 2025
c3d5e8e
Bump pnpm to 10.8.1 (#45956)
renovate[bot] Apr 20, 2025
d06640a
Bump @vitejs/plugin-react to ^4.4.1 (#45960)
renovate[bot] Apr 20, 2025
05e3079
Bump aws-cli to 5.3.1 (#45961)
renovate[bot] Apr 20, 2025
def70d8
Bump git-url-parse to ^16.1.0 (#45962)
renovate[bot] Apr 20, 2025
7be70a0
Bump GitHub Actions (#45963)
renovate[bot] Apr 20, 2025
79af153
Bump jsdom to ^26.1.0 (#45964)
renovate[bot] Apr 20, 2025
55becc1
Bump nx to ^20.8.0 (#45966)
renovate[bot] Apr 20, 2025
0292d6b
Bump @types/react to ^19.1.2 (#45953)
renovate[bot] Apr 20, 2025
518a2e4
Bump next to ^15.3.1 (#45955)
renovate[bot] Apr 20, 2025
bcb6bf5
Bump react-router to ^7.5.1 (#45957)
renovate[bot] Apr 20, 2025
942a8d5
Bump vitest to ^3.1.1 (#45969)
renovate[bot] Apr 20, 2025
9e255e4
Bump typescript-eslint to ^8.30.1 (#45968)
renovate[bot] Apr 20, 2025
95f859a
Bump tailwindcss to ^4.1.4 (#45958)
renovate[bot] Apr 20, 2025
2edbd96
[docs-v5] Add AccordionSummary to the breaking change migration (#45947)
siriwatknp Apr 21, 2025
e3d807e
Bump MUI X to 7.29.0 (#45965)
renovate[bot] Apr 21, 2025
f0dfbae
[docs] Add Tailwind CSS v4 integration guide (#45906)
siriwatknp Apr 22, 2025
adb0a76
[docs-infra] StackBlitz WebContainer demos (#45924)
Janpot Apr 22, 2025
f32c76c
[docs] Add `InitColorSchemeScript` docs and API (#45927)
siriwatknp Apr 23, 2025
4a9d277
[website] Update X roadmap and features in pricing list (#45980)
cherniavskii Apr 23, 2025
55f2624
Add Codecov bundler plugin
calvin-codecov Apr 18, 2025
38b0ef2
chore: CI changes
calvin-codecov Apr 24, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .circleci/config.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
version: 2.1
orbs:
aws-cli: circleci/aws-cli@5.2.0
aws-cli: circleci/aws-cli@5.3.1
aws-s3: circleci/[email protected]

parameters:
Expand Down
13 changes: 11 additions & 2 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,13 +18,13 @@ jobs:
runs-on: ubuntu-latest
steps:
- run: echo "${{ github.actor }}"
- uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
with:
fetch-depth: 0
- name: Set up pnpm
uses: pnpm/action-setup@a7487c7e89a18df4991f7f222e4898a00d66ddda # v4.1.0
- name: Use Node.js 20.x
uses: actions/setup-node@1d0ff469b7ec7b3cb9d8673fde0c81c44821de2a # v4.2.0
uses: actions/setup-node@49933ea5288caeca8642d1e84afbd3f7d6820020 # v4.4.0
with:
node-version: 20
cache: 'pnpm' # https://github.com/actions/setup-node/blob/main/docs/advanced-usage.md#caching-packages-dependencies
Expand Down Expand Up @@ -66,3 +66,12 @@ jobs:
run: |
git remote -v
pnpm release:tag --dryRun

codecov-step:
name: Codecov
runs-on: ubuntu-latest
steps:
- name: Upload coverage to Codecov
run: pnpm codecov
env:
CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN || ''}}
2 changes: 1 addition & 1 deletion apps/bare-next-app/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
"devDependencies": {
"@pigment-css/nextjs-plugin": "0.0.30",
"@types/node": "^20.17.30",
"@types/react": "^19.1.1",
"@types/react": "^19.1.2",
"@types/react-dom": "^19.1.2",
"eslint": "^8.57.1",
"typescript": "^5.8.3"
Expand Down
2 changes: 1 addition & 1 deletion apps/pigment-css-next-app/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
"devDependencies": {
"@pigment-css/nextjs-plugin": "0.0.30",
"@types/node": "^20.17.30",
"@types/react": "^19.1.1",
"@types/react": "^19.1.2",
"@types/react-dom": "^19.1.2",
"eslint": "^8.57.1",
"typescript": "^5.8.3"
Expand Down
4 changes: 2 additions & 2 deletions apps/pigment-css-vite-app/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -28,10 +28,10 @@
"@babel/preset-react": "^7.26.3",
"@babel/preset-typescript": "^7.27.0",
"@pigment-css/vite-plugin": "0.0.30",
"@types/react": "^19.1.1",
"@types/react": "^19.1.2",
"@types/react-dom": "^19.1.2",
"@types/webfontloader": "^1.6.38",
"@vitejs/plugin-react": "^4.3.4",
"@vitejs/plugin-react": "^4.4.1",
"postcss": "^8.5.3",
"postcss-combine-media-query": "^1.0.1",
"vite": "5.4.18",
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,137 @@
---
productId: material-ui
title: InitColorSchemeScript component
components: InitColorSchemeScript
githubSource: packages/mui-material/src/InitColorSchemeScript
---

# InitColorSchemeScript

<p class="description">The InitColorSchemeScript component eliminates dark mode flickering in server-side-rendered applications.</p>

## Introduction

The `InitColorSchemeScript` component is used to remove the dark mode flicker that can occur in server-side-rendered (SSR) applications.
This script runs before React to attach an attribute based on the user preference so that the correct color mode is applied on first render.

For the best user experience, you should implement this component in any server-rendered Material UI app that supports both light and dark modes.

## Basics

First, enable CSS variables with `colorSchemeSelector: 'data'` in your theme.

```js
import { ThemeProvider, createTheme } from '@mui/material/styles';

const theme = createTheme({
cssVariables: {
colorSchemeSelector: 'data',
},
});

function App() {
return <ThemeProvider theme={theme}>{/* Your app */}</ThemeProvider>;
}
```

Then, render the `InitColorSchemeScript` component as the first child of the `<body>` tag.

The sections below detail where to render the `InitColorSchemeScript` component when working with Next.js.

### Next.js App Router

Place the `InitColorSchemeScript` component in the root `layout` file:

```js title="src/app/layout.tsx"
import InitColorSchemeScript from '@mui/material/InitColorSchemeScript';

export default function RootLayout(props: { children: React.ReactNode }) {
return (
<html lang="en" suppressHydrationWarning>
<body>
<InitColorSchemeScript />
{props.children}
</body>
</html>
);
}
```

### Next.js Pages Router

Place the `InitColorSchemeScript` component in a custom `_document` file:

```js title="pages/_document.tsx"
import { Html, Head, Main, NextScript } from 'next/document';
import InitColorSchemeScript from '@mui/material/InitColorSchemeScript';

export default function MyDocument(props) {
return (
<Html lang="en">
<Head>{/* tags */}</Head>
<body>
<InitColorSchemeScript />
<Main />
<NextScript />
</body>
</Html>
);
}
```

## Customization

### Class attribute

To attach classes to DOM elements, set the `attribute` prop to `"class"`.

```js
<InitColorSchemeScript attribute="class" />
```

This sets the class name on the color scheme node (which defaults to `<html>`) according to the user's system preference.

```html
<html class="dark"></html>
```

### Arbitrary attribute

To attach arbitrary attributes to DOM elements, use `%s` as a placeholder on the `attribute` prop.

```js
<InitColorSchemeScript attribute="[data-theme='%s']" /> // <html data-theme="dark">
<InitColorSchemeScript attribute=".mode-%s" /> // <html class="mode-dark">
```

### Default mode

Set the `defaultMode` prop to specify the default mode when the user first visits the page.

For example, if you want users to see the dark mode on their first visit, set the `defaultMode` prop to `"dark"`.

```js
<InitColorSchemeScript defaultMode="dark" />
```

## Caveats

### Attribute

When customizing the `attribute` prop, make sure to set the `colorSchemeSelector` in the theme to match the attribute you are using.

```js
const theme = createTheme({
cssVariables: {
colorSchemeSelector: 'same value as the `attribute` prop',
},
});
```

### Default mode

When customizing the `defaultMode` prop, make sure to do the same with the `ThemeProvider` component:

```js
<ThemeProvider theme={theme} defaultMode="dark">
```
Original file line number Diff line number Diff line change
Expand Up @@ -26,49 +26,51 @@ createTheme({ cssVariables: { cssVarPrefix: '' } });

To toggle between modes manually, set the `colorSchemeSelector` with one of the following selectors:

<codeblock>

```js class
createTheme({
colorSchemes: { light: true, dark: true },
cssVariables: {
colorSchemeSelector: 'class'
}
});

// CSS Result
.light { ... }
.dark { ... }
```

```js data
createTheme({
colorSchemes: { light: true, dark: true },
cssVariables: {
colorSchemeSelector: 'data'
}
});

// CSS Result
[data-light] { ... }
[data-dark] { ... }
```

```js string
// The value must start with dot (.) for class or square brackets ([]) for data
createTheme({
colorSchemes: { light: true, dark: true },
cssVariables: {
colorSchemeSelector: '.theme-%s'
}
});

// CSS Result
.theme-light { ... }
.theme-dark { ... }
```

</codeblock>
- `class`: adds a class to the `<html>` element.

```js class
createTheme({
colorSchemes: { light: true, dark: true },
cssVariables: {
colorSchemeSelector: 'class'
}
});

// CSS Result
.light { ... }
.dark { ... }
```

- `data`: adds a data attribute to the `<html>` element.

```js data
createTheme({
colorSchemes: { light: true, dark: true },
cssVariables: {
colorSchemeSelector: 'data'
}
});

// CSS Result
[data-light] { ... }
[data-dark] { ... }
```

- `string`: adds a custom selector to the `<html>` element.

```js string
// The value must start with dot (.) for class or square brackets ([]) for data
createTheme({
colorSchemes: { light: true, dark: true },
cssVariables: {
colorSchemeSelector: '.theme-%s'
}
});

// CSS Result
.theme-light { ... }
.theme-dark { ... }
```

Then, use `useColorScheme` hook to switch between modes:

Expand Down Expand Up @@ -162,7 +164,7 @@ If you have such a condition, replace it with the [`theme.applyStyles()` functio
}
```

Next, if you have a custom selector that is **not** `media`, add the `InitColorSchemeScript` component based on the framework that you are using:
Next, if you have a custom selector that is **not** `media`, add the [`InitColorSchemeScript`](/material-ui/react-init-color-scheme-script/) component based on the framework that you are using:

:::success
The `attribute` has to be the same as the one you set in the `colorSchemeSelector` property:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ There are examples for the following styling solutions:
- [Styled Components](#styled-components)
- [CSS Modules](#css-modules)
- [Emotion](#emotion)
- [Tailwind CSS](#tailwind-css)
- [Tailwind CSS v3](#tailwind-css-v3)
- [~~JSS~~ TSS](#jss-tss)

## Plain CSS
Expand Down Expand Up @@ -573,11 +573,15 @@ It works exactly like styled components. You can [use the same guide](/material-

It works exactly like styled components. You can [use the same guide](/material-ui/integrations/interoperability/#styled-components).

## Tailwind CSS
## Tailwind CSS v3

![stars](https://img.shields.io/github/stars/tailwindlabs/tailwindcss.svg?style=social&label=Star)
![npm](https://img.shields.io/npm/dm/tailwindcss)

:::info
For Tailwind CSS v4, please refer to the [v4 integration guide](/material-ui/integrations/tailwindcss/tailwindcss-v4/).
:::

### Setup

<!-- #repo-reference -->
Expand Down
34 changes: 34 additions & 0 deletions docs/data/material/integrations/tailwindcss/TextFieldTailwind.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
import * as React from 'react';
import FormControl from '@mui/material/FormControl';
import InputLabel from '@mui/material/InputLabel';
import Input from '@mui/material/Input';
import FormHelperText from '@mui/material/FormHelperText';

export default function TextFieldTailwind() {
return (
<FormControl>
<InputLabel
shrink
htmlFor="component-outlined"
className="relative top-0 left-0 transform-none text-sm font-medium text-neutral-800 dark:text-neutral-200 pointer-events-auto mb-0.5"
>
Name
</InputLabel>
<Input
id="component-outlined"
placeholder="Type your name"
slotProps={{
root: {
className:
'mt-0 -ml-0.5 px-2 h-10 border-1 border-neutral-300 dark:border-neutral-700 rounded-md has-[input:focus-visible]:outline-2 has-[input:focus-visible]:outline-offset-2 disabled:cursor-not-allowed disabled:opacity-50 md:text-sm before:hidden after:hidden',
},
input: {
className:
'placeholder:opacity-100 placeholder:text-neutral-400 dark:placeholder:text-neutral-500',
},
}}
/>
<FormHelperText className="ml-0">Some important helper text</FormHelperText>
</FormControl>
);
}
Loading