A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from https://github.com/muhajirdev/monad-ui/ below:

GitHub - muhajirdev/monad-ui: Utility First CSS-in-JS

# 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>
  );
}

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.

Type Array Responsive API Object Responsive API High Order Responsive API Dynamic ✅ ✅ ✅ Static ❌ ❌ ✅

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

ISC License, Copyright (c) 2020, Muhammad Muhajir


RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4