All Projects → donavon → styled-units

donavon / styled-units

Licence: MIT License
You might want to try https://github.com/donavon/styled-shortcuts instead

Programming Languages

javascript
184084 projects - #8 most used programming language

Projects that are alternatives of or similar to styled-units

prosemirror-react-typescript-example
Minimal boilerplate to start a project with ProseMirror, React, TypeScript
Stars: ✭ 67 (+378.57%)
Mutual labels:  styled-components
sendight-frontend
P2P File sharing
Stars: ✭ 53 (+278.57%)
Mutual labels:  styled-components
nextjs-with-material-ui-and-styled-components
Next.js with material-ui and styled-components
Stars: ✭ 100 (+614.29%)
Mutual labels:  styled-components
web-template-project
This repository contains a template for nodeJS and ReactJs projects using TypeScript.
Stars: ✭ 18 (+28.57%)
Mutual labels:  styled-components
react-easy-ssr
🔥 React Starter Project with Webpack 5, Babel 7, TypeScript, Redux-saga, Styled-components, React-jss, Split code, Server Side Rendering.
Stars: ✭ 31 (+121.43%)
Mutual labels:  styled-components
smores-react
🍭 Marshmallow React components
Stars: ✭ 34 (+142.86%)
Mutual labels:  styled-components
gatsby-starter-shopifypwa
💚🛒💚 Bodega is a Shopify PWA using Gatsby JS + Netlify CMS
Stars: ✭ 100 (+614.29%)
Mutual labels:  styled-components
minesweeper
💣Minesweeper game written with React
Stars: ✭ 18 (+28.57%)
Mutual labels:  styled-components
mugiwara
fast minimal CSS-in-JS created to reduce size of CSS injected
Stars: ✭ 11 (-21.43%)
Mutual labels:  styled-components
styled-components-docs-zh
💅 styled-components 中文文档翻译 🏇持续施工中
Stars: ✭ 160 (+1042.86%)
Mutual labels:  styled-components
twin.examples
Packed with examples for different frameworks, this repo helps you get started with twin a whole lot faster.
Stars: ✭ 320 (+2185.71%)
Mutual labels:  styled-components
youtube-clone-mercadolivre
Mercado Livre (Sale Page) UI Clone
Stars: ✭ 24 (+71.43%)
Mutual labels:  styled-components
react-awesome-notifications
A beautiful fully customizable React + Redux notification system built with styled-components
Stars: ✭ 29 (+107.14%)
Mutual labels:  styled-components
react-native-whirlwind
Whirlwind is a utility-first styling framework specifically designed for React Native. It is heavily inspired by Tachyons and Tailwind CSS and uses low-level building blocks for rapidly building custom designs.
Stars: ✭ 91 (+550%)
Mutual labels:  styled-components
medly-components
🧩 Medly components provides numerous themable react components, each with multiple varitaions of sizes, colors, position etc.
Stars: ✭ 66 (+371.43%)
Mutual labels:  styled-components
monorail
🚝 Monorail | Cyber Design System
Stars: ✭ 14 (+0%)
Mutual labels:  styled-components
paygreen-ui
UI PayGreen Components: React, Styled Component
Stars: ✭ 29 (+107.14%)
Mutual labels:  styled-components
styled-svg
A styled-components generator for SVG files to use in react
Stars: ✭ 37 (+164.29%)
Mutual labels:  styled-components
desvg
🌅 Converts SVG files into components 🌞
Stars: ✭ 79 (+464.29%)
Mutual labels:  styled-components
react-universal-starter
React@16, react-router@4, redux and webpack@4 starter project
Stars: ✭ 44 (+214.29%)
Mutual labels:  styled-components

styled-units 💅

Build Status npm version Coverage Status

TL;DR

  • Provides convenient unit property helper functions that go hand-in-hand with styled-components 💅
  • Small footprint with No Dependencies!
  • For example, instead of doing this:
    width: ${({ percent }) => `${percent}%`};
    you do this:
    width: ${pct('percent')};

Install

$ npm i --save styled-units

Usage:

import styled from 'styled-components';
import { em, px, pct } from 'styled-units';

const Button = styled.button`
  padding: ${em('padding')};
  border-radius: ${px('borderRadius')};
  width: ${pct('width')};
`;

Button.defaultProps = {
  padding: 1,
  borderRadius: 4,
  width: 100,
};

Then use it like this.

<Button borderRadius={5} padding={3}>Press Me</Button>

API

Supported "units":

Function Description
px Returns the property specified with the "px" suffix
em Returns the property specified with the "em" suffix
rem Returns the property specified with the "rem" suffix
pct Returns the property specified with the "%" suffix
vw Returns the property specified with the "vw" suffix
vh Returns the property specified with the "vh" suffix
prop Returns the property specified "as-is"

Live

Check out this live example on CodeSandbox.

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].