All Projects → muhajirdev → monad-ui

muhajirdev / monad-ui

Licence: ISC license
Utility First CSS-in-JS

Programming Languages

javascript
184084 projects - #8 most used programming language

Projects that are alternatives of or similar to monad-ui

Xstyled
A utility-first CSS-in-JS framework built for React. 💅👩‍🎤⚡️
Stars: ✭ 1,835 (+5460.61%)
Mutual labels:  emotion, css-in-js
Filbert Js
A lightweight(~1kb) css-in-js framework
Stars: ✭ 167 (+406.06%)
Mutual labels:  emotion, css-in-js
React Next Boilerplate
🚀 A basis for reducing the configuration of your projects with nextJS, best development practices and popular libraries in the developer community.
Stars: ✭ 129 (+290.91%)
Mutual labels:  emotion, css-in-js
Horror
😱 React HTML elements with CSS-in-JS
Stars: ✭ 78 (+136.36%)
Mutual labels:  emotion, css-in-js
Styled Components Vs Emotion
a short doc comparing the popular CSS-in-JS libraries styled-components and emotion
Stars: ✭ 204 (+518.18%)
Mutual labels:  emotion, css-in-js
Onno
Responsive style props for building themed design systems
Stars: ✭ 95 (+187.88%)
Mutual labels:  emotion, css-in-js
Goober
🥜 goober, a less than 1KB 🎉 css-in-js alternative with a familiar API
Stars: ✭ 2,317 (+6921.21%)
Mutual labels:  emotion, css-in-js
Styled Tools
Useful interpolated functions for CSS-in-JS
Stars: ✭ 761 (+2206.06%)
Mutual labels:  emotion, css-in-js
Emotion
👩‍🎤 CSS-in-JS library designed for high performance style composition
Stars: ✭ 14,177 (+42860.61%)
Mutual labels:  emotion, css-in-js
Grid
This package has moved and renamed
Stars: ✭ 2,079 (+6200%)
Mutual labels:  emotion, css-in-js
Flame
Component library for building Lightspeed products
Stars: ✭ 65 (+96.97%)
Mutual labels:  emotion, css-in-js
Xwind
Tailwind CSS as a templating language in JS and CSS-in-JS
Stars: ✭ 249 (+654.55%)
Mutual labels:  emotion, css-in-js
Emotion Module
💖 Emotion module for Nuxt.js
Stars: ✭ 47 (+42.42%)
Mutual labels:  emotion, css-in-js
Css In React
🍭 CSS in React - Learn the best CSS in JS frameworks by example
Stars: ✭ 101 (+206.06%)
Mutual labels:  emotion, css-in-js
Styled System
⬢ Style props for rapid UI development
Stars: ✭ 7,126 (+21493.94%)
Mutual labels:  emotion, css-in-js
Next Dark Mode
🌑 Enable dark mode for Next.js apps
Stars: ✭ 133 (+303.03%)
Mutual labels:  emotion, css-in-js
Design System Utils
👩‍🎨 Access your design tokens with ease
Stars: ✭ 465 (+1309.09%)
Mutual labels:  emotion, css-in-js
Facepaint
Responsive style values for css-in-js.
Stars: ✭ 523 (+1484.85%)
Mutual labels:  emotion, css-in-js
Vue Emotion
Seamlessly use emotion (CSS-in-JS) with Vue.js
Stars: ✭ 173 (+424.24%)
Mutual labels:  emotion, css-in-js
Styled Ppx
Typed styled components in Reason, OCaml and ReScript
Stars: ✭ 236 (+615.15%)
Mutual labels:  emotion, css-in-js

monad-ui

Inspired by Rebass, TailwindCSS, Smooth UI, and Material UI.
Implemented in Emotion.

npm downloads license



Usage

Basic example

# using npm
npm install monad-ui

# using yarn
yarn add monad-ui
import * as S from 'monad-ui';

// blue background
function Example() {
  return (
    <div css={S.bg('blue')}>
      Lorem ipsum dolor sit, amet consectetur adipisicing elit.
    </div>
  );
}

// blue background and red text color
function Example() {
  return (
    <div css={[S.bg('blue'), S.color('red')]}>
      Lorem ipsum dolor sit, amet consectetur adipisicing elit.
    </div>
  );
}

Responsive styles

Monad UI has four breakpoints (view source):

const breakpoints = {
  sm: '576px',
  md: '768px',
  lg: '992px',
  xl: '1200px'
};

There are many ways to implement responsive styles:

  1. Array Responsive API

    import * as S from 'monad-ui';
    
    function Example() {
      return (
        <div css={S.bg(['red', 'green', 'blue'])}>
          Lorem ipsum dolor sit, amet consectetur adipisicing elit.
        </div>
      );
    }

    Example above will change the div's background to red. When the screen size is above 576px, it will be green. When the screen size is above 768px, it will be blue. And so on.

  2. Object Responsive API

    import * as S from 'monad-ui';
    
    function Example() {
      return (
        <div css={S.bg({ sm: 'red', lg: 'blue' })}>
          Lorem ipsum dolor sit, amet consectetur adipisicing elit.
        </div>
      );
    }

    Note that md is not specified. When it's not specified, it will take the previous value, which is red in this case.

  3. Higher-order Function Responsive API

    import * as S from 'monad-ui';
    
    function Example() {
      return (
        <div css={S.up('sm')(S.hidden)}>
          Lorem ipsum dolor sit, amet consectetur adipisicing elit.
        </div>
      );
    }

    Example above will hide the div when the screen size is above 576px.

    import * as S from 'monad-ui';
    
    function Example() {
      return (
        <div css={S.up('sm')(S.bg('blue'))}>
          Lorem ipsum dolor sit, amet consectetur adipisicing elit.
        </div>
      );
    }

    Example above will change the div's background into blue when the screen size is above 576px.

Static vs Dynamic APIs

  • Dynamic type accept arguments (e.g. S.bg('blue')).
  • Static type does not accept arguments. (e.g. S.down('md')(S.hidden)).
Type Array Responsive API Object Responsive API High Order Responsive API
Dynamic
Static

Available APIs

View all available APIs at ./docs/available-apis.md.

FAQs

  • Do I always have to import * as S from 'monad-ui'?

    If you only use a few styles, you can also import and use like this:

    import { bg, hidden } from 'monad-ui';
    
    function Example() {
      return (
        <div css={bg('blue')}>
          Lorem ipsum dolor sit, amet consectetur adipisicing elit.
        </div>
      );
    }
  • Too many styles?

    Consider extracting your style outside like this:

    import { css } from '@emotion/core';
    import { bg, color } from 'monad-ui';
    
    const style = css([bg('blue'), color('red')]);
    
    function Example() {
      return (
        <div class={style}>
          Lorem ipsum dolor sit, amet consectetur adipisicing elit.
        </div>
      );
    }

License

ISC License, Copyright (c) 2020, Muhammad Muhajir

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].