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

react-with-styles

Package Overview
Dependencies
Maintainers
4
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]

  • 5.0.0
  • unpublished
  • latest
  • Source
  • npm
  • Socket score

Version published
Maintainers
4
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

FAQs

Package last updated on 07 Apr 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