InitColorSchemeScript API
InitColorSchemeScript API (색상 스킴 초기화 스크립트 API)
InitColorSchemeScript는 브라우저에서 페이지를 렌더링하기 전에 저장된 색상 스킴을 적용하는 인라인 스크립트를 주입해 주는 컴포넌트예요. 이 페이지에서는 이 컴포넌트의 props와 기타 API를 하나씩 설명해 드릴게요.
출처: 문서
본문
데모 (Demos)
이 React 컴포넌트의 사용법과 세부 사항은 컴포넌트 데모 페이지에서 확인할 수 있어요.
- InitColorSchemeScript
Import
import InitColorSchemeScript from '@mui/material/InitColorSchemeScript';
// 또는
import { InitColorSchemeScript } from '@mui/material';
번들 크기를 줄이는 방법이 궁금하시다면, 이 차이에 대한 가이드 문서를 읽어 보시면 좋아요.
Props
네이티브 컴포넌트의 props도 그대로 사용할 수 있어요.
| Name | Type | Default | Description |
|---|---|---|---|
| attribute | string | 'data-mui-color-scheme' | DOM attribute for applying a color scheme. |
| colorSchemeNode | string | 'document.documentElement' | The node (provided as string) used to attach the color-scheme attribute. |
| colorSchemeStorageKey | string | 'mui-color-scheme' | localStorage key used to store colorScheme. |
| defaultDarkColorScheme | string | 'dark' | The default color scheme to be used in dark mode. |
| defaultLightColorScheme | string | 'light' | The default color scheme to be used in light mode. |
| defaultMode | 'dark'| 'light'| 'system' | 'system' | The default mode when the storage is empty (user's first visit). |
| modeStorageKey | string | 'mui-mode' | localStorage key used to store mode. |
| nonce | string | - | Nonce string to pass to the inline script for CSP headers. |
이 컴포넌트는 ref를 가질 수 없어요.
소스 코드 (Source code)
이 페이지에서 원하는 정보를 찾지 못했다면, 컴포넌트의 구현 코드를 살펴보시면 더 자세한 내용을 확인할 수 있어요.