Theme Switch

January 16, 2023 ยท View on GitHub

ThemeSwitch component can be used to provide a amazing animation when user changing the state of system functionalities and preferences using Toggle Switch.

๐ŸŽฌ Preview


ThemeSwitch
alt tag

Default Usage


import React from 'react';
import { StyleSheet, View } from 'react-native';
import { ThemeSwitch } from 'react-native-skia-catalog';

const ThemeSwitchScreen = () => (
  <View style={styles.container}>
    <ThemeSwitch />
  </View>
);

const styles = StyleSheet.create({
  container: {
    flex: 1,
    justifyContent: 'center',
    alignItems: 'center',
  },
});

export default ThemeSwitchScreen;

Custom Usage


import React from 'react';
import { StyleSheet, View } from 'react-native';
import { ThemeSwitch } from 'react-native-skia-catalog';

const ThemeSwitchScreen = () => (
  <View style={styles.container}>
    <ThemeSwitch
      size={340}
      lightThemeColor={'#59abdd'}
      darkThemeColor={'#0f1341'}
    />
  </View>
);

const styles = StyleSheet.create({
  container: {
    flex: 1,
    justifyContent: 'center',
    alignItems: 'center',
  },
});

export default ThemeSwitchScreen;

๐ŸŽฌ Custom Usage Preview


alt tag

Properties

PropsDefaultTypeDescription
size300numberSize of Switch.
lightThemeColor#59abddstringSwitch color while the mode is OFF.
darkThemeColor#0f1341stringSwitch color while the mode is ON.
onToggle() => {}(status: string) => voidCallback function that gives the value of Switch either light or dark in parameter based on mode.

๐ŸŽฌ Preview Example


Theme Switch