bass-component
v1.0.0
Published
React component for styling elements with a Basscss-like API
Downloads
2
Readme
bass-component
React component for styling elements with a Basscss-like API
npm i bass-components
import React from 'react'
import Bass from 'bass-component'
const App = props => (
<Bass p3>
<Bass.h1
mt0
mb2
h1
children='Hello'
/>
</Bass>
)
Bass-component will automatically insert the minimal amount of CSS needed to render into the head of the document.
API
Props
All bass-component style props are booleans.
Display:
block
display: blockinlineBlock
display: inline-blockinline
display: inlineflex
display: flexinlineFlex
display: inline-flextable
display: tabletableCell
display: tableCellleft
float: leftright
float: right
Typography:
h1
font-size: 32pxh2
font-size: 24pxh3
font-size: 20pxh4
font-size: 16pxh5
font-size: 14pxh6
font-size: 12pxbold
font-weight: boldcenter
text-align: centercaps
text-transform: uppercase; letter-spacing: 0.2emnowrap
white-space: nowrap
Margin:
m0
margin: 0m1
margin: 8pxm2
margin: 16pxm3
margin: 32pxm4
margin: 64pxmt0
margin-top: 0mt1
margin-top: 8pxmt2
margin-top: 16pxmt3
margin-top: 32pxmt4
margin-top: 64pxmr0
margin-right: 0mr1
margin-right: 8pxmr2
margin-right: 16pxmr3
margin-right: 32pxmr4
margin-right: 64pxmb0
margin-bottom: 0mb1
margin-bottom: 8pxmb2
margin-bottom: 16pxmb3
margin-bottom: 32pxmb4
margin-bottom: 64pxml0
margin-left: 0ml1
margin-left: 8pxml2
margin-left: 16pxml3
margin-left: 32pxml4
margin-left: 64pxmx0
margin-left: 0; margin-right: 0mx1
margin-left: 8px; margin-right: 8pxmx2
margin-left: 16px; margin-right: 16pxmx3
margin-left: 32px; margin-right: 32pxmx4
margin-left: 64px; margin-right: 64pxmy0
margin-top: 0; margin-bottom: 0my1
margin-top: 8px; margin-bottom: 8pxmy2
margin-top: 16px; margin-bottom: 16pxmy3
margin-top: 32px; margin-bottom: 32pxmy4
margin-top: 64px; margin-bottom: 64pxmx-1
margin-top: -8px; margin-bottom: -8pxmx-2
margin-top: -16px; margin-bottom: -16pxmx-3
margin-top: -32px; margin-bottom: -32pxmx-4
margin-top: -64px; margin-bottom: -64pxmlAuto
margin-left: automrAuto
margin-right: automxAuto
margin-left: auto; margin-right: auto
Padding:
p0
padding: 0p1
padding: 8pxp2
padding: 16pxp3
padding: 32pxp4
padding: 64pxpt0
padding-top: 0pt1
padding-top: 8pxpt2
padding-top: 16pxpt3
padding-top: 32pxpt4
padding-top: 64pxpr0
padding-right: 0pr1
padding-right: 8pxpr2
padding-right: 16pxpr3
padding-right: 32pxpr4
padding-right: 64pxpb0
padding-bottom: 0pb1
padding-bottom: 8pxpb2
padding-bottom: 16pxpb3
padding-bottom: 32pxpb4
padding-bottom: 64pxpl0
padding-left: 0pl1
padding-left: 8pxpl2
padding-left: 16pxpl3
padding-left: 32pxpl4
padding-left: 64pxpx0
padding-left: 0; padding-right: 0px1
padding-left: 8px; padding-right: 8pxpx2
padding-left: 16px; padding-right: 16pxpx3
padding-left: 32px; padding-right: 32pxpx4
padding-left: 64px; padding-right: 64pxpy0
padding-top: 0; padding-bottom: 0py1
padding-top: 8px; padding-bottom: 8pxpy2
padding-top: 16px; padding-bottom: 16pxpy3
padding-top: 32px; padding-bottom: 32pxpy4
padding-top: 64px; padding-bottom: 64px
HTML element
By default the Bass component renders a <div>
.
To change the underlying element, use dot notation for the component
or use the is
prop.
<Bass.h1 />
<Bass is='h1' />
Bass.component()
A styled-components-like higher order component for applying bass-component props to any component that accepts className
as a prop.
import { Link } from 'react-router'
import Bass from 'bass-component'
const BassLink = Bass.component(Link)
Bass.css()
Gets a CSS ruleset string based on what has rendered – useful for server-side rendering.
MIT License