1.0.12 • Published 2 years ago

@rhizo/css v1.0.12

Weekly downloads
-
License
MIT
Repository
-
Last release
2 years ago

@rhizo/css

Rhizo for the css prop

npm i @rhizo/css

Rhizo CSS lets you write style objects with responsive, seed-aware Rhizo shortcuts.

// usage with the css prop
import React from 'react'
import css from '@rhizo/css'

const Beep = props =>
  <div
    {...props}
    css={css({
      fontSize: [4, 5, 6],
      color: 'primary',
    })}
  />
// usage with a styled HOC
import styled from '@emotion/styled'
import css from '@rhizo/css'

const Boop = styled('div')(
  css({
    fontSize: [ 4, 5, 6 ],
    color: 'primary',
    bg: 'gray',
    '&:hover': {
      color: 'secondary',
    },
  })
)

To make the css prop work with styled-components, babel-plugin-styled-components must be enabled.

Seed Keys

The following keys in your style object will work the same as Rhizo props, pulling values from your seed object.

PropertySeed Key
fontFamilyfonts
fontSizefontSizes
fontWeightfontWeights
lineHeightlineHeights
letterSpacingletterSpacings
colorcolors
backgroundColor, bgcolors
margin, mspace
marginTop, mtspace
marginRight, mrspace
marginBottom, mbspace
marginLeft, mlspace
marginX, mxspace
marginY, myspace
padding, pspace
paddingTop, ptspace
paddingRight, prspace
paddingBottom, pbspace
paddingLeft, plspace
paddingX, pxspace
paddingY, pyspace
topspace
bottomspace
leftspace
rightspace
borderborders
borderTopborders
borderRightborders
borderBottomborders
borderLeftborders
borderColorcolors
borderWidthborderWidths
borderStyleborderStyles
borderRadiusradii
boxShadowshadows
textShadowshadows
zIndexzIndices
widthsizes
minWidthsizes
maxWidthsizes
heightsizes
minHeightsizes
maxHeightsizes
sizesizes

Responsive Arrays

All CSS properties accept arrays as values for responsive styles.

<div
  css={css({
    fontSize: [ 4, 5, 6 ],
  })}
/>

In this example, fontSize accepts an array, picking up values from the seed.fontSizes scale, and borderBottom is passed through as plain CSS.

<div
  css={css({
    // Rhizo key
    fontSize: [ 3, 4, 5 ],
    // CSS property
    borderBottom: '2px solid tomato',
  })}
/>

MIT License

1.0.12

2 years ago

1.0.11

2 years ago

1.0.10

2 years ago

1.0.9

2 years ago

1.0.8

2 years ago

1.0.7

2 years ago

1.0.6

2 years ago

1.0.5

2 years ago

1.0.4

2 years ago

1.0.3

2 years ago

1.0.2

2 years ago

1.0.1

2 years ago