API Reference
Sparkle Design System API / theme/src
theme/src
Section titled “theme/src”Classes
Section titled “Classes”ThemeValidator
Section titled “ThemeValidator”Theme configuration validator Provides comprehensive validation for design token integrity, accessibility compliance, and platform compatibility
Example
Section titled “Example”const validator = new ThemeValidator()const result = validator.validate(lightTokens)
if (!result.isValid) { console.error('Theme validation failed:', result.errors)}Methods
Section titled “Methods”validate()
Section titled “validate()”validate(
theme,options):ValidationResult
Validate a theme configuration
Parameters
Section titled “Parameters”ThemeConfig
Theme configuration to validate
options
Section titled “options”ValidationOptions = {}
Validation options
Returns
Section titled “Returns”Validation result with errors and warnings
TokenTransformer
Section titled “TokenTransformer”Cross-platform token transformer Converts design tokens between web (CSS custom properties) and native (React Native StyleSheet) formats
Example
Section titled “Example”const transformer = new TokenTransformer()
// Transform to web formatconst webResult = transformer.transform(lightTokens, { platform: 'web' })
// Transform to native formatconst nativeResult = transformer.transform(lightTokens, { platform: 'native' })Methods
Section titled “Methods”clearCache()
Section titled “clearCache()”clearCache():
void
Clear transformation cache Useful when tokens have been updated
Returns
Section titled “Returns”void
getCacheStats()
Section titled “getCacheStats()”getCacheStats():
object
Get cache statistics
Returns
Section titled “Returns”object
keys:
string[]
size:
number
toNative()
Section titled “toNative()”toNative(
tokens,options):NativeTheme
Transform tokens to native format (React Native StyleSheet)
Parameters
Section titled “Parameters”tokens
Section titled “tokens”ThemeConfig
Source theme configuration
options
Section titled “options”Omit<TransformOptions, "platform"> = {}
Native-specific options
Returns
Section titled “Returns”Native theme object
toWeb()
Section titled “toWeb()”toWeb(
tokens,options):CSSCustomProperties
Transform tokens to web format (CSS custom properties)
Parameters
Section titled “Parameters”tokens
Section titled “tokens”ThemeConfig
Source theme configuration
options
Section titled “options”Omit<TransformOptions, "platform"> = {}
Web-specific options
Returns
Section titled “Returns”CSS custom properties object
transform()
Section titled “transform()”transform(
tokens,options):TransformResult
Transform design tokens to target platform format
Parameters
Section titled “Parameters”tokens
Section titled “tokens”ThemeConfig
Source theme configuration
options
Section titled “options”Transformation options
Returns
Section titled “Returns”Transformation result with platform-specific tokens
Interfaces
Section titled “Interfaces”CSSCustomProperties
Section titled “CSSCustomProperties”Type for CSS custom properties object
NativeShadowStyle
Section titled “NativeShadowStyle”React Native shadow style properties Platform-specific shadow handling for iOS and Android
NativeTheme
Section titled “NativeTheme”React Native StyleSheet compatible theme object Numeric values for dimensions, hex/rgb colors for colors
NativeThemeProviderProps
Section titled “NativeThemeProviderProps”Props for the NativeThemeProvider component
Properties
Section titled “Properties”children
Section titled “children”children:
ReactNode
Child components that will have access to the theme context
defaultTheme?
Section titled “defaultTheme?”
optionaldefaultTheme:ThemeMode
Default theme mode to use on first load
Default
Section titled “Default”'system'disableSystemTheme?
Section titled “disableSystemTheme?”
optionaldisableSystemTheme:boolean
Whether to disable system theme detection
Default
Section titled “Default”falsestorageKey?
Section titled “storageKey?”
optionalstorageKey:string
Storage key for persisting theme preference
Default
Section titled “Default”'sparkle-theme'themes?
Section titled “themes?”
optionalthemes:ThemeCollection
Custom theme configurations to override defaults
Default
Section titled “Default”{ light: lightTokens, dark: darkTokens }updateStatusBar?
Section titled “updateStatusBar?”
optionalupdateStatusBar:boolean
Whether to automatically update StatusBar style based on theme
Default
Section titled “Default”trueThemeCollection
Section titled “ThemeCollection”Theme collection mapping theme modes to their configurations
ThemeContextValue
Section titled “ThemeContextValue”Theme context value interface providing complete theme state and controls
Properties
Section titled “Properties”activeTheme
Section titled “activeTheme”activeTheme:
ThemeMode
Currently selected theme mode (user preference)
error:
Error|null
Error state if theme loading or validation fails
isLoading
Section titled “isLoading”isLoading:
boolean
Loading state during theme initialization or transitions
setTheme()
Section titled “setTheme()”setTheme: (
theme) =>void
Function to change the theme mode Handles persistence and CSS variable updates automatically
Parameters
Section titled “Parameters”Returns
Section titled “Returns”void
systemTheme
Section titled “systemTheme”systemTheme:
SystemColorScheme
System detected color scheme (independent of user preference)
theme:
ThemeConfig
Current active theme configuration with all design tokens
ThemePluginOptions
Section titled “ThemePluginOptions”Configuration options for the theme plugin
Properties
Section titled “Properties”darkMode?
Section titled “darkMode?”
optionaldarkMode:boolean
Whether to include dark mode support (default: true)
includeCSSVariables?
Section titled “includeCSSVariables?”
optionalincludeCSSVariables:boolean
Whether to include CSS custom properties in base layer (default: true)
prefix?
Section titled “prefix?”
optionalprefix:string
Prefix for CSS custom properties (default: ‘theme’)
rootSelector?
Section titled “rootSelector?”
optionalrootSelector:string
Selector for CSS custom properties (default: ':root')
ThemeProviderProps
Section titled “ThemeProviderProps”Props for the ThemeProvider component
Properties
Section titled “Properties”children
Section titled “children”children:
ReactNode
Child components that will have access to the theme context
cssSelector?
Section titled “cssSelector?”
optionalcssSelector:string
CSS selector for injecting CSS variables
Default
Section titled “Default”':root'defaultTheme?
Section titled “defaultTheme?”
optionaldefaultTheme:ThemeMode
Default theme mode to use on first load
Default
Section titled “Default”'system'disableSystemTheme?
Section titled “disableSystemTheme?”
optionaldisableSystemTheme:boolean
Whether to disable system theme detection
Default
Section titled “Default”falsestorageKey?
Section titled “storageKey?”
optionalstorageKey:string
Storage key for persisting theme preference
Default
Section titled “Default”'sparkle-theme'themes?
Section titled “themes?”
optionalthemes:ThemeCollection
Custom theme configurations to override defaults
Default
Section titled “Default”{ light: lightTokens, dark: darkTokens }ThemeShowcaseProps
Section titled “ThemeShowcaseProps”Theme examples and showcase components (Phase 5)
Properties
Section titled “Properties”className?
Section titled “className?”
optionalclassName:string
Additional CSS classes for the showcase container
showColorPalette?
Section titled “showColorPalette?”
optionalshowColorPalette:boolean
Whether to show the color palette demonstration
Default
Section titled “Default”trueshowComponents?
Section titled “showComponents?”
optionalshowComponents:boolean
Whether to show component demonstrations
Default
Section titled “Default”trueshowSemanticColors?
Section titled “showSemanticColors?”
optionalshowSemanticColors:boolean
Whether to show semantic color demonstrations
Default
Section titled “Default”trueTransformOptions
Section titled “TransformOptions”Token transformation options
Properties
Section titled “Properties”baseFontSize?
Section titled “baseFontSize?”
optionalbaseFontSize:number
Base font size for rem calculations (default: 16)
flattenColors?
Section titled “flattenColors?”
optionalflattenColors:boolean
Whether to flatten nested color objects for easier access (native only)
platform
Section titled “platform”platform:
Platform
Target platform for transformation
prefix?
Section titled “prefix?”
optionalprefix:string
Optional prefix for CSS variables (web only)
selector?
Section titled “selector?”
optionalselector:string
CSS selector for CSS variables (web only, default: ':root')
TransformResult
Section titled “TransformResult”Result of token transformation
Properties
Section titled “Properties”metadata
Section titled “metadata”metadata:
object
Transformation metadata
options
Section titled “options”options:
TransformOptions
tokenCount
Section titled “tokenCount”tokenCount:
number
transformedAt
Section titled “transformedAt”transformedAt:
string
platform
Section titled “platform”platform:
Platform
Target platform
source
Section titled “source”source:
ThemeConfig
Original theme configuration
tokens
Section titled “tokens”tokens:
NativeTheme|CSSCustomProperties
Transformed tokens (CSS variables for web, native theme for mobile)
ValidationError
Section titled “ValidationError”Validation error with specific context
Properties
Section titled “Properties”expected?
Section titled “expected?”
optionalexpected:string
Expected value type or format
message
Section titled “message”message:
string
Error message describing the validation failure
path:
string
Path to the invalid property (e.g., ‘colors.primary.500’)
severity
Section titled “severity”severity:
"error"|"warning"
Severity level of the validation error
value:
unknown
The invalid value that caused the error
ValidationOptions
Section titled “ValidationOptions”Validation options for theme configuration
Properties
Section titled “Properties”checkRequiredProperties?
Section titled “checkRequiredProperties?”
optionalcheckRequiredProperties:boolean
Whether to check for missing required properties (default: true)
minContrastRatio?
Section titled “minContrastRatio?”
optionalminContrastRatio:number
Minimum contrast ratio for WCAG compliance (default: 4.5 for AA)
strictMode?
Section titled “strictMode?”
optionalstrictMode:boolean
Whether to treat warnings as errors (default: false)
validateColorContrast?
Section titled “validateColorContrast?”
optionalvalidateColorContrast:boolean
Whether to validate color contrast ratios (default: true)
validateCSSValues?
Section titled “validateCSSValues?”
optionalvalidateCSSValues:boolean
Whether to validate CSS value formats (default: true)
validateSpacingScale?
Section titled “validateSpacingScale?”
optionalvalidateSpacingScale:boolean
Whether to validate spacing scale consistency (default: true)
ValidationResult
Section titled “ValidationResult”Validation result containing errors and warnings
Properties
Section titled “Properties”errors
Section titled “errors”errors:
ValidationError[]
Array of validation errors found
isValid
Section titled “isValid”isValid:
boolean
Whether the theme configuration is valid
summary
Section titled “summary”summary:
object
Summary of validation results
checkedProperties
Section titled “checkedProperties”checkedProperties:
number
totalErrors
Section titled “totalErrors”totalErrors:
number
totalWarnings
Section titled “totalWarnings”totalWarnings:
number
warnings
Section titled “warnings”warnings:
ValidationError[]
Array of validation warnings found
Type Aliases
Section titled “Type Aliases”Platform
Section titled “Platform”Platform =
"web"|"native"
Platform target for token transformation
SystemColorScheme
Section titled “SystemColorScheme”SystemColorScheme =
"light"|"dark"
System detected color scheme
ThemeMode
Section titled “ThemeMode”ThemeMode =
"light"|"dark"|"system"
Theme mode options supporting light/dark themes and system preference
Variables
Section titled “Variables”baseTokens
Section titled “baseTokens”
constbaseTokens:ThemeConfig
Base design tokens following Design Tokens Community Group specification These tokens serve as the foundation for all theme variants
https://design-tokens.github.io/community-group/
darkTokens
Section titled “darkTokens”
constdarkTokens:ThemeConfig
Dark theme tokens extending the base design system Optimized for dark mode interfaces with appropriate contrast ratios Following WCAG AA guidelines for accessibility
DEFAULT_THEME_STORAGE_KEY
Section titled “DEFAULT_THEME_STORAGE_KEY”
constDEFAULT_THEME_STORAGE_KEY:"sparkle-theme"='sparkle-theme'
Default storage key for theme persistence
defaultTransformer
Section titled “defaultTransformer”
constdefaultTransformer:TokenTransformer
Default transformer instance for convenience
lightTokens
Section titled “lightTokens”
constlightTokens:ThemeConfig
Light theme tokens extending the base design system Optimized for light mode interfaces with appropriate contrast ratios
nativePersistence
Section titled “nativePersistence”
constnativePersistence:object
React Native-specific theme persistence using AsyncStorage
Type Declaration
Section titled “Type Declaration”isSupported()
Section titled “isSupported()”isSupported():
Promise<boolean>
Checks if AsyncStorage is available
Returns
Section titled “Returns”Promise<boolean>
Promise resolving to true if AsyncStorage is supported and accessible
load()
Section titled “load()”load(
storageKey):Promise<ThemeMode|null>
Loads theme preference from AsyncStorage
Parameters
Section titled “Parameters”storageKey
Section titled “storageKey”string = DEFAULT_THEME_STORAGE_KEY
The key to use for AsyncStorage
Returns
Section titled “Returns”Promise<ThemeMode | null>
Promise resolving to the stored theme mode or null if not found
remove()
Section titled “remove()”remove(
storageKey):Promise<void>
Removes theme preference from AsyncStorage
Parameters
Section titled “Parameters”storageKey
Section titled “storageKey”string = DEFAULT_THEME_STORAGE_KEY
The key to use for AsyncStorage
Returns
Section titled “Returns”Promise<void>
save()
Section titled “save()”save(
theme,storageKey):Promise<void>
Saves theme preference to AsyncStorage
Parameters
Section titled “Parameters”The theme mode to save
storageKey
Section titled “storageKey”string = DEFAULT_THEME_STORAGE_KEY
The key to use for AsyncStorage
Returns
Section titled “Returns”Promise<void>
persistenceMigration
Section titled “persistenceMigration”
constpersistenceMigration:object
Utility for migrating theme data between storage keys Useful for updating storage keys while preserving user preferences
Type Declaration
Section titled “Type Declaration”isValidThemeMode()
Section titled “isValidThemeMode()”isValidThemeMode(
value):value is ThemeMode
Validates that a stored value is a valid theme mode
Parameters
Section titled “Parameters”unknown
The value to validate
Returns
Section titled “Returns”value is ThemeMode
true if the value is a valid ThemeMode
migrate()
Section titled “migrate()”migrate(
oldKey,newKey,removeOld):Promise<boolean>
Migrates theme preference from old key to new key
Parameters
Section titled “Parameters”oldKey
Section titled “oldKey”string
The old storage key
newKey
Section titled “newKey”string
The new storage key
removeOld
Section titled “removeOld”boolean = true
Whether to remove the old key after migration
Returns
Section titled “Returns”Promise<boolean>
Promise
ThemeContext
Section titled “ThemeContext”
constThemeContext:Context<ThemeContextValue|null>
React Context for theme management across the application
This context provides access to:
- Current theme configuration with design tokens
- Theme switching functionality with persistence
- System color scheme detection
- Loading and error states
Must be used within a ThemeProvider or NativeThemeProvider
Example
Section titled “Example”const { theme, setTheme, activeTheme } = useTheme();
// Access theme tokensconst primaryColor = theme.colors.primary[500];
// Change themesetTheme('dark');themePersistence
Section titled “themePersistence”
constthemePersistence:object
Platform-agnostic theme persistence interface Automatically detects the environment and uses appropriate storage method
Type Declaration
Section titled “Type Declaration”isSupported()
Section titled “isSupported()”isSupported():
boolean|Promise<boolean>
Checks if storage is available
Returns
Section titled “Returns”boolean | Promise<boolean>
boolean or Promise
load()
Section titled “load()”load(
storageKey?):ThemeMode|Promise<ThemeMode | null> |null
Loads theme preference from appropriate storage
Parameters
Section titled “Parameters”storageKey?
Section titled “storageKey?”string
The key to use for storage
Returns
Section titled “Returns”ThemeMode | Promise<ThemeMode | null> | null
Theme mode or Promise
remove()
Section titled “remove()”remove(
storageKey?):void|Promise<void>
Removes theme preference from appropriate storage
Parameters
Section titled “Parameters”storageKey?
Section titled “storageKey?”string
The key to use for storage
Returns
Section titled “Returns”void | Promise<void>
void or Promise
save()
Section titled “save()”save(
theme,storageKey?):void|Promise<void>
Saves theme preference to appropriate storage
Parameters
Section titled “Parameters”The theme mode to save
storageKey?
Section titled “storageKey?”string
The key to use for storage
Returns
Section titled “Returns”void | Promise<void>
void or Promise
tokenUtils
Section titled “tokenUtils”
consttokenUtils:object
Utility functions for common token transformations
Type Declaration
Section titled “Type Declaration”compareThemes()
Section titled “compareThemes()”compareThemes(
theme1,theme2):string[]
Compare two theme configurations for differences
Parameters
Section titled “Parameters”theme1
Section titled “theme1”ThemeConfig
First theme configuration
theme2
Section titled “theme2”ThemeConfig
Second theme configuration
Returns
Section titled “Returns”string[]
Array of differences found
extractColorPalette()
Section titled “extractColorPalette()”extractColorPalette(
theme,colorKey):Record<string|number,string> |undefined
Extract specific color palette from theme
Parameters
Section titled “Parameters”ThemeConfig
Theme configuration
colorKey
Section titled “colorKey”string
Color key to extract (e.g., ‘primary’, ‘neutral’)
Returns
Section titled “Returns”Record<string | number, string> | undefined
Color scale object
getColorNames()
Section titled “getColorNames()”getColorNames(
theme):string[]
Get all semantic color names from theme
Parameters
Section titled “Parameters”ThemeConfig
Theme configuration
Returns
Section titled “Returns”string[]
Array of color names
getSpacingKeys()
Section titled “getSpacingKeys()”getSpacingKeys(
theme): (string|number)[]
Get all spacing scale keys
Parameters
Section titled “Parameters”ThemeConfig
Theme configuration
Returns
Section titled “Returns”(string | number)[]
Array of spacing keys
mergeThemes()
Section titled “mergeThemes()”mergeThemes(
baseTheme,overrideTheme):ThemeConfig
Merge two theme configurations with the second overriding the first
Parameters
Section titled “Parameters”baseTheme
Section titled “baseTheme”ThemeConfig
Base theme configuration
overrideTheme
Section titled “overrideTheme”Partial<ThemeConfig>
Theme configuration to merge on top
Returns
Section titled “Returns”ThemeConfig
Merged theme configuration
webPersistence
Section titled “webPersistence”
constwebPersistence:object
Web-specific theme persistence using localStorage
Type Declaration
Section titled “Type Declaration”isSupported()
Section titled “isSupported()”isSupported():
boolean
Checks if localStorage is available
Returns
Section titled “Returns”boolean
true if localStorage is supported and accessible
load()
Section titled “load()”load(
storageKey):ThemeMode|null
Loads theme preference from localStorage
Parameters
Section titled “Parameters”storageKey
Section titled “storageKey”string = DEFAULT_THEME_STORAGE_KEY
The key to use for localStorage
Returns
Section titled “Returns”ThemeMode | null
The stored theme mode or null if not found
remove()
Section titled “remove()”remove(
storageKey):void
Removes theme preference from localStorage
Parameters
Section titled “Parameters”storageKey
Section titled “storageKey”string = DEFAULT_THEME_STORAGE_KEY
The key to use for localStorage
Returns
Section titled “Returns”void
save()
Section titled “save()”save(
theme,storageKey):void
Saves theme preference to localStorage
Parameters
Section titled “Parameters”The theme mode to save
storageKey
Section titled “storageKey”string = DEFAULT_THEME_STORAGE_KEY
The key to use for localStorage
Returns
Section titled “Returns”void
Functions
Section titled “Functions”createNativeStyleUtils()
Section titled “createNativeStyleUtils()”createNativeStyleUtils(
nativeTheme):object
Creates a React Native StyleSheet from native theme tokens Convenience function for creating common styles
Parameters
Section titled “Parameters”nativeTheme
Section titled “nativeTheme”Native theme object
Returns
Section titled “Returns”object
Object with common style utilities
borderRadius
Section titled “borderRadius”borderRadius:
object
Index Signature
Section titled “Index Signature”[k: string]: object
colors
Section titled “colors”colors:
object
Index Signature
Section titled “Index Signature”[key: string]: { backgroundColor: string; } | { color: string; }
shadows
Section titled “shadows”shadows:
Record<string,NativeShadowStyle> =nativeTheme.shadows
spacing
Section titled “spacing”spacing:
object
Index Signature
Section titled “Index Signature”[key: string]: { padding: number; } | { margin: number; }
typography
Section titled “typography”typography:
object
Index Signature
Section titled “Index Signature”[k: string]: object
Example
Section titled “Example”const theme = generateNativeTheme(lightTokens)const styleUtils = createNativeStyleUtils(theme)
// Use in component<View style={[styleUtils.spacing.p4, styleUtils.colors.bgPrimary]} />createThemePlugin()
Section titled “createThemePlugin()”createThemePlugin(
themes,options):PluginWithConfig
Creates a Tailwind CSS plugin for theme integration
Parameters
Section titled “Parameters”themes
Section titled “themes”Record<string, ThemeConfig>
options
Section titled “options”ThemePluginOptions = {}
Returns
Section titled “Returns”PluginWithConfig
cssPropertiesToString()
Section titled “cssPropertiesToString()”cssPropertiesToString(
cssVariables,selector):string
Converts CSS custom properties object to CSS string for injection into stylesheets or CSS-in-JS
Parameters
Section titled “Parameters”cssVariables
Section titled “cssVariables”Object of CSS custom properties
selector
Section titled “selector”string = ':root'
CSS selector to apply variables to (default: ':root')
Returns
Section titled “Returns”string
CSS string with custom properties
Example
Section titled “Example”const cssString = cssPropertiesToString(cssVars)// Returns: ':root { --sparkle-color-primary-500: #3b82f6; }'cssVar()
Section titled “cssVar()”cssVar(
category,key,fallback?,prefix?):string
Creates CSS variable reference string for use in other CSS
Parameters
Section titled “Parameters”category
Section titled “category”string
Token category (e.g., ‘color’, ‘spacing’)
string
Token key path (e.g., ‘primary-500’, ‘md’)
fallback?
Section titled “fallback?”string
Optional fallback value
prefix?
Section titled “prefix?”string = 'sparkle'
Optional prefix (default: ‘sparkle’)
Returns
Section titled “Returns”string
CSS var() function string
Example
Section titled “Example”cssVar('color', 'primary-500')// Returns: 'var(--sparkle-color-primary-500)'
cssVar('spacing', 'md', '1rem', 'app')// Returns: 'var(--app-spacing-md, 1rem)'generateCSSVariables()
Section titled “generateCSSVariables()”generateCSSVariables(
tokens,prefix):CSSCustomProperties
Generates CSS custom properties (CSS variables) from design tokens for web platform integration with Tailwind CSS and other frameworks
Parameters
Section titled “Parameters”tokens
Section titled “tokens”ThemeConfig
Theme configuration object with design tokens
prefix
Section titled “prefix”string = 'sparkle'
Optional prefix for CSS variable names (default: ‘sparkle’)
Returns
Section titled “Returns”Object of CSS custom properties that can be applied to :root
Example
Section titled “Example”const cssVars = generateCSSVariables(lightTokens)// Returns: { '--sparkle-color-primary-500': '#3b82f6', ... }generateNativeTheme()
Section titled “generateNativeTheme()”generateNativeTheme(
tokens,options):NativeTheme
Generates React Native StyleSheet compatible theme object from design tokens Converts CSS values to React Native compatible numeric and string values
Parameters
Section titled “Parameters”tokens
Section titled “tokens”ThemeConfig
Theme configuration object with design tokens
options
Section titled “options”Configuration options for conversion
baseFontSize?
Section titled “baseFontSize?”number
Base font size for rem conversion (default: 16)
flattenColors?
Section titled “flattenColors?”boolean
Whether to flatten nested color objects (default: true)
Returns
Section titled “Returns”Native theme object compatible with React Native StyleSheet
Example
Section titled “Example”const nativeTheme = generateNativeTheme(lightTokens)const styles = StyleSheet.create({ container: { backgroundColor: nativeTheme.colors.background.primary, padding: nativeTheme.spacing[4], }})generateThemeCSS()
Section titled “generateThemeCSS()”generateThemeCSS(
tokens,options):string
Generates CSS custom properties string directly from theme tokens Convenience function that combines generateCSSVariables and cssPropertiesToString
Parameters
Section titled “Parameters”tokens
Section titled “tokens”ThemeConfig
Theme configuration object
options
Section titled “options”Configuration options
prefix?
Section titled “prefix?”string
Optional prefix for CSS variable names (default: ‘sparkle’)
selector?
Section titled “selector?”string
CSS selector to apply variables to (default: ':root')
Returns
Section titled “Returns”string
CSS string ready for injection
Example
Section titled “Example”const css = generateThemeCSS(lightTokens, { prefix: 'app' })document.querySelector('style')?.appendChild(document.createTextNode(css))isValidTheme()
Section titled “isValidTheme()”isValidTheme(
theme):boolean
Check if a theme configuration passes basic validation Quick boolean check without detailed error information
Parameters
Section titled “Parameters”ThemeConfig
Theme configuration to check
Returns
Section titled “Returns”boolean
Whether the theme is valid
NativeThemeProvider()
Section titled “NativeThemeProvider()”NativeThemeProvider(
__namedParameters):Element
NativeThemeProvider component for React Native applications
Provides theme management functionality with:
- Automatic system theme detection using Appearance API
- AsyncStorage persistence
- StatusBar style integration
- Theme validation and error handling
Parameters
Section titled “Parameters”__namedParameters
Section titled “__namedParameters”Returns
Section titled “Returns”Element
Example
Section titled “Example”function App() { return ( <NativeThemeProvider defaultTheme="system"> <YourAppComponents /> </NativeThemeProvider> );}parseNumericValue()
Section titled “parseNumericValue()”parseNumericValue(
value,baseFontSize):number
Converts a CSS dimension string to a React Native numeric value Handles rem, px, and numeric values
Parameters
Section titled “Parameters”CSS dimension string (e.g., ‘1rem’, ‘16px’, ‘1.5’)
string | number
baseFontSize
Section titled “baseFontSize”number = 16
Base font size for rem conversion (default: 16)
Returns
Section titled “Returns”number
Numeric value for React Native
Example
Section titled “Example”parseNumericValue('1rem') // Returns: 16parseNumericValue('24px') // Returns: 24parseNumericValue('1.5') // Returns: 1.5parseShadow()
Section titled “parseShadow()”parseShadow(
boxShadow):NativeShadowStyle
Converts CSS box-shadow to React Native shadow properties Attempts to extract shadow values for cross-platform compatibility
Parameters
Section titled “Parameters”boxShadow
Section titled “boxShadow”string
CSS box-shadow string
Returns
Section titled “Returns”Native shadow style object
Example
Section titled “Example”parseShadow('0 4px 6px rgba(0, 0, 0, 0.1)')// Returns: { shadowOffset: { width: 0, height: 4 }, shadowRadius: 6, ... }ThemeProvider()
Section titled “ThemeProvider()”ThemeProvider(
__namedParameters):Element
ThemeProvider component for web applications
Provides theme management functionality with:
- Automatic system theme detection
- localStorage persistence
- CSS variable injection
- Theme validation and error handling
Parameters
Section titled “Parameters”__namedParameters
Section titled “__namedParameters”Returns
Section titled “Returns”Element
Example
Section titled “Example”function App() { return ( <ThemeProvider defaultTheme="system"> <YourAppComponents /> </ThemeProvider> );}ThemeShowcase()
Section titled “ThemeShowcase()”ThemeShowcase(
__namedParameters):Element
ThemeShowcase component demonstrating all theme features
This component provides a comprehensive demonstration of the theme system including color palettes, semantic colors, and themed UI components.
Parameters
Section titled “Parameters”__namedParameters
Section titled “__namedParameters”Returns
Section titled “Returns”Element
useColorScheme()
Section titled “useColorScheme()”useColorScheme():
"light"|"dark"
Custom hook for detecting system color scheme preference Works on both web (via matchMedia) and React Native (via Appearance API)
Returns
Section titled “Returns”"light" | "dark"
Current system color scheme (‘light’ or ‘dark’)
useTheme()
Section titled “useTheme()”useTheme():
ThemeContextValue
Custom hook for consuming theme context
Returns
Section titled “Returns”Theme context value with current theme and controls
Throws
Section titled “Throws”Error if used outside of ThemeProvider or NativeThemeProvider
validateTheme()
Section titled “validateTheme()”validateTheme(
theme,options?):ValidationResult
Quick validation function for theme configuration Convenience function that creates a validator instance and runs validation
Parameters
Section titled “Parameters”ThemeConfig
Theme configuration to validate
options?
Section titled “options?”Validation options
Returns
Section titled “Returns”Validation result
Example
Section titled “Example”const result = validateTheme(lightTokens, { strictMode: true })if (!result.isValid) { console.error('Theme validation failed')}