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

styled-system

Package Overview
Dependencies
Maintainers
2
Versions
149
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

styled-system

Responsive, theme-based style props for building design systems with React

  • 5.1.5
  • latest
  • npm
  • Socket score

Version published
Weekly downloads
592K
increased by15.3%
Maintainers
2
Weekly downloads
 
Created

What is styled-system?

Styled System is a utility for creating consistent, responsive, and theme-based design systems in React. It provides a set of functions and utilities to style components using a system of design tokens, such as spacing, colors, and typography, making it easier to build UI components that adhere to a design system.

What are styled-system's main functionalities?

Responsive Styles

Styled System allows you to define responsive styles using arrays. The `p` prop sets padding, `bg` sets background color, and `width` sets the width of the component. The values in the arrays correspond to different breakpoints.

const Box = styled.div`
  ${space}
  ${color}
  ${layout}
`;

<Box p={[1, 2, 3]} bg={['red', 'green', 'blue']} width={[1, 1/2, 1/4]} />

Theme-based Design

Styled System integrates with a theme object to provide consistent styling across your application. The `color` and `space` utilities use the theme to apply styles.

const theme = {
  colors: {
    primary: 'blue',
    secondary: 'green',
  },
  space: [0, 4, 8, 16, 32],
};

const Box = styled.div`
  ${color}
  ${space}
`;

<Box color='primary' p={2} />

Utility Functions

Styled System provides utility functions like `space`, `color`, and `layout` that can be used to style components. These functions map props to CSS properties based on the theme.

import { space, color, layout } from 'styled-system';

const Box = styled.div`
  ${space}
  ${color}
  ${layout}
`;

<Box m={2} p={3} bg='primary' width={1/2} />

Other packages similar to styled-system

Keywords

FAQs

Package last updated on 17 Feb 2020

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