Navigation Menu

Skip to content

cawfree/react-native-split-styles

Folders and files

NameName
Last commit message
Last commit date

Latest commit

ย 

History

5 Commits
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 

Repository files navigation

react-native-split-styles

Split StyleSheet keys into dedicated groups to help ease the routing of style groups to nested components.

๐Ÿš€ Installing

yarn add react-native-split-styles

โœ๏ธ Usage

Below, we show how we can take a single style prop and route the contents based on predefined presets to separate nested components.

import React from "react";
import { StyleSheet, View, TextInput, Button } from "react-native";

import { useSplitStyles } from "react-native-split-styles";

import FlexPreset from "react-native-split-styles/dist/presets/Flex";
import ShadowPreset from "react-native-split-styles/dist/presets/Shadow";
import TextPreset from "react-native-split-styles/dist/presets/Text";

export default ({ style }) => {
  const [flex, shadow, text, { ...extras }] = useSplitStyles(style, FlexPreset, ShadowPreset, TextPreset);
  return (
    <View style={flex}>
      <TextInput style={text} />
      <Button style={shadow} />
    </View>
  );
};

โœŒ๏ธ License

MIT

About

๐Ÿ’… Split StyleSheet keys into dedicated objects to help ease the routing of styles for nested components.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published