Palette
색상 팔레트를 설정하는 함수로, 라이트 및 다크 모드를 포함하며 사용자 정의 색상 팔레트를 지원합니다.
Interactive exampleTheme 로컬 웹 예제
예제를 선택하면 현재 저장소 소스로 만든 Expo Web 화면을 불러옵니다.
웹 미지원 또는 플랫폼 종속 기능은 실제 iOS·Android 앱에서 확인하세요.
기본 사용법
import { useTheme } from '@0610studio/zs-ui';
function MyComponent() {
const { palette } = useTheme();
return (
<View>
<View style={{ backgroundColor: palette.primary.main }}>
<ZSText color="white">Primary Main</ZSText>
</View>
<ZSText color="base">Base Text</ZSText>
<ZSText color="secondary">Secondary Text</ZSText>
</View>
);
}
테마 모드
모드 전환
const { palette } = useTheme();
// 테마 토글
palette.toggleTheme();
// 시스템 색상 스키마 사용 여부 설정
palette.setUseSystemColorScheme(true);
// 현재 모드 확인
const currentMode = palette.mode; // 'light' | 'dark'
const isUsingSystem = palette.isUsingSystemColorScheme; // boolean