본문으로 건너뛰기

시작하기

각 테마 색상은 primary, secondary, danger, warning, success, information과 같은 다양한 상태에 맞게 정의되어 있으며, 기본 배경과 텍스트 색상도 포함되어있습니다.

ThemeProvider로 감싸서 전체 앱에서 useTheme를 사용할 수 있도록 설정합니다.

import React from 'react';
import { ThemeProvider } from '@0610studio/zs-ui';
import App from './App';

const Root = () => (
<ThemeProvider>
<App />
</ThemeProvider>
);

export default Root;

시스템 색상 설정 감지

useColorScheme 훅을 사용하여 시스템의 다크 모드 설정을 감지합니다.

themeMode와 useSystemColorScheme 값은 AsyncStorage에 저장되어 있어 사용자가 앱을 다시 열 때 동일한 테마가 적용됩니다.


테마 토글 함수

toggleTheme : 사용자가 테마를 라이트와 다크 모드 사이에서 전환할 수 있습니다. 이 함수는 AsyncStorage에 모드를 저장합니다.


속성별 타입

1. ThemeProviderProps

속성 이름데이터 타입기본값설명
childrenReact.ReactNodeRequiredThemeProvider로 감싸질 React 컴포넌트
themeFontsThemeFontsundefined폰트 weight 별 폰트 패밀리 이름 매핑 (400·700 필수)
isDarkModeEnabledbooleantruefalse면 시스템 설정을 무시하고 라이트 모드로 고정
customPalette(config) => ThemeundefinedthemeFactory 로 만든 커스텀 팔레트 함수
foldableFoldableConfigundefined폴더블 펼침 상태의 단일 화면 최대 폭 설정

2. ThemePropsuseTheme() 반환값

속성 이름데이터 타입설명
palettePalette테마 색상 팔레트 + 모드 제어 함수
typographyTypographyVariantsProps타이포그래피 스타일 객체
elevationElevationStyles레벨 0~9 의 boxShadow 스타일 맵
foldableFoldableConfig폴더블 관련 설정값

3. PaletteTheme 을 확장하며 모드 제어 API 를 더한다

속성 이름데이터 타입설명
mode'light' | 'dark'현재 테마 모드
isUsingSystemColorSchemeboolean시스템 색상 모드 사용 여부
setUseSystemColorScheme(useSystem: boolean) => void시스템 색상 모드 활성화/비활성화
toggleTheme() => void라이트 ↔ 다크 수동 전환

4. Theme

속성 이름데이터 타입설명
mode'light' | 'dark'팔레트가 생성된 모드
primaryColorPaletteExtend주요 색상 (5~100 + main·lighter·light·dark·darker)
secondaryColorPalette보조 색상 (5~100 + main)
danger / warning / success / information / greyColorPalette상태·중립 색상
textThemeTextType텍스트 색상 (base·secondary·disabled·white·black 및 상태색)
backgroundThemeBackground배경 색상 (base·layer1·layer2·neutral 및 상태색)
elevationShadowstring[]레벨별 그림자 색상 배열 (0~9)
modalBgColorstring모달 오버레이 배경색
mainColorMainColors각 시맨틱 색상의 main 값 모음

5. TypographyVariantsProps

각 스타일은 1~6 서브스타일을 가집니다.

속성 이름데이터 타입설명
headingTypoNumber가장 크고 두드러진 제목
titleTypoNumber페이지·섹션 제목
subTitleTypoNumber부제목
labelTypoNumber버튼·입력 필드 레이블
bodyTypoNumber본문
captionTypoNumber작은 부가 텍스트
themeFontsThemeFonts적용된 폰트 매핑 (선택)