GithubHelp home page GithubHelp logo

dimitreee / styled-system Goto Github PK

View Code? Open in Web Editor NEW

This project forked from styled-system/styled-system

0.0 1.0 0.0 1.76 MB

Design system utilities for styled-components and other css-in-js libraries

Home Page: https://jxnblk.com/styled-system/

License: MIT License

JavaScript 100.00%

styled-system's Introduction

styled-system

Design system utilities for styled-components and other css-in-js libraries

Build Status Coverage Downloads Version

npm i styled-system

Features

  • Add style props that hook into your own theme
  • Responsive prop values for quickly setting responsive font-size, margin, padding, width, and more
  • Influenced by constraint-based design system principles
  • Typographic scale
  • Spacing scale for margin and padding
  • Default 8px grid
  • Works with any color palette
  • Works with most css-in-js libraries, including styled-components, glamorous, emotion, fela, and cxs
  • Used in Rebass, Grid Styled, and the Priceline Design System

"This is honestly my favourite way to build UI components right now party parrot"

Varun Vachhar

"The future of css-in-js is going to look something like styled-system with its responsive values."

Kye Hohenberger

"Coming from @tachyons_css, the styled-system utilities from @jxnblk is the missing link I’ve been looking for."

Nathan Young

"If you make websites/apps with React check out Styled System if you haven't already. You will be amazed at how much faster you can build."

David Yeiser

Table of Contents

Usage

// Example uses styled-components, but styled-system works with most other css-in-js libraries as well
import styled from 'styled-components'
import { space, width, fontSize, color } from 'styled-system'

// Add styled-system functions to your component
const Box = styled.div`
  ${space}
  ${width}
  ${fontSize}
  ${color}
`

Each style function exposes its own set of component props that handle styles based on values defined in a theme.

// width: 50%
<Box width={1/2} />

// font-size: 20px (theme.fontSizes[4])
<Box fontSize={4} />

// margin: 16px (theme.space[2])
<Box m={2} />

// padding: 32px (theme.space[3])
<Box p={3} />

// color
<Box color='tomato' />

// color: #333 (theme.colors.gray[0])
<Box color='grays.0' />

// background color
<Box bg='tomato' />

Responsive Style Props

Set responsive width, margin, padding, font-size, and other properties with a shorthand array syntax. Read more

// responsive width
<Box width={[ 1, 1/2, 1/4 ]} />

// responsive font-size
<Box fontSize={[ 2, 3, 4 ]} />

// responsive margin
<Box m={[ 1, 2, 3 ]} />

// responsive padding
<Box p={[ 1, 2, 3 ]} />

To learn more, see the Getting Started guide or read the docs.

Docs

Optional Packages


Further Reading

Related

MIT License

styled-system's People

Contributors

allforabit avatar andarist avatar braposo avatar broccolini avatar browniefed avatar colebemis avatar corygibbons avatar ferdinandsalis avatar glennr avatar ifyoumakeit avatar janv avatar johno avatar josepot avatar joshrosenstein avatar jxnblk avatar kikobeats avatar kingscooty avatar lucasmotta avatar mikehobi avatar oomathias avatar prichodko avatar ramonakira avatar selrond avatar shanecav avatar smith-kyle avatar stevenambs avatar t49tran avatar theutz avatar tiborv avatar tkh44 avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.