You're Invited:Meet the Socket Team at BlackHat and DEF CON in Las Vegas, Aug 4-6.RSVP
Socket
Book a DemoInstallSign in
Socket

react-with-styles

Package Overview
Dependencies
Maintainers
5
Versions
36
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

react-with-styles

[![Build Status][travis-svg]][travis-url] [![dependency status][deps-svg]][deps-url] [![dev dependency status][dev-deps-svg]][dev-deps-url] [![License][license-image]][license-url] [![Downloads][downloads-image]][downloads-url]

4.0.0
Source
npmnpm
Version published
Weekly downloads
449K
-1.08%
Maintainers
5
Weekly downloads
 
Created

What is react-with-styles?

react-with-styles is a library that allows you to use styles in a React application in a way that is consistent and maintainable. It provides a way to define styles in JavaScript and apply them to your components, supporting various styling solutions like CSS-in-JS, Aphrodite, and more.

What are react-with-styles's main functionalities?

Defining Styles

You can define styles as a function that takes a theme object and returns a styles object. This allows for dynamic and theme-based styling.

const styles = ({ color, unit }) => ({
  button: {
    backgroundColor: color.primary,
    padding: unit * 2,
  },
});

Applying Styles

You can apply the defined styles to your components using the `withStyles` higher-order component. The `css` function is used to apply the styles to the component.

import { withStyles } from 'react-with-styles';

const Button = ({ styles }) => (
  <button {...css(styles.button)}>Click me</button>
);

export default withStyles(({ color, unit }) => ({
  button: {
    backgroundColor: color.primary,
    padding: unit * 2,
  },
}))(Button);

Theming

You can provide a theme to your application using the `ThemeProvider` component. This theme can then be accessed in your styles functions to create consistent and dynamic styles.

import { ThemeProvider } from 'react-with-styles';

const theme = {
  color: {
    primary: 'blue',
  },
  unit: 8,
};

const App = () => (
  <ThemeProvider theme={theme}>
    <Button />
  </ThemeProvider>
);

Other packages similar to react-with-styles

Keywords

react

FAQs

Package last updated on 04 Sep 2019

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