Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

react-native-sugar-style

Package Overview
Dependencies
Maintainers
1
Versions
21
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

react-native-sugar-style

React Native Stylesheet alternative with theme support

  • 0.1.22
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
25
increased by47.06%
Maintainers
1
Weekly downloads
 
Created
Source

🚀React Native Sugar Style

https://www.npmjs.com/package/react-native-sugar-style (🧪 Experimental)


🎨 Theme based alternative for React Native StyleSheet

✨ Support responsive values as array

📐 Reduce computing device height & width in every component

📱 Works on android/ios/web (expo/react-native)

Install

yarn add react-native-sugar-style
npm i react-native-sugar-style

Usage

STEP 1: style.tsx

Define configurations for your theme, for more verbose example see this file.

import Sugar from "react-native-sugar-style";

const dark = {
  background: "#2b2b2b",
  text: "#ffffff",
};

const light = {
  background: "#fbfbfb",
  text: "#000000",
};

export const { StyleSheet } = Sugar(light);

export default StyleSheet;

STEP 2: component.tsx

Use StyleSheet as you do normally do in components

import React from "react";
import { View, Text } from "react-native";
import { StyleSheet } from "./style";

const Component = () => {
  return (
    <View style={styles.container}>
      <Text style={styles.text}>Hello World</Text>
    </View>
  );
};

const styles = StyleSheet.create((theme) => ({
  container: {
    height: constants.height,
    width: constants.width,
    backgroundColor: theme.background,
    flexDirection: ["column", "row"],
  },
  text: {
    color: theme.text,
  },
}));

Demo

Scan and run with expo go app, run the example project for a more detailed example. https://expo.io/@mohit23x/projects/react-native-sugar-style or try the react native web version

Scan QR with expo app

More

Guide

Constants

API

Live Example

Why this Package

Acknowledgement

Caveats

Keywords

FAQs

Package last updated on 07 Mar 2021

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc