Socket
Socket
Sign inDemoInstall

@master/css.react

Package Overview
Dependencies
7
Maintainers
2
Versions
205
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    @master/css.react

React hooks and components for Master CSS


Version published
Weekly downloads
198
increased by39.44%
Maintainers
2
Created
Weekly downloads
 

Readme

Source

Master CSS

React hooks and components for Master CSS

NPM Version NPM Version NPM package ( download / month ) JSDelivr hits (npm scoped) Discord online Follow @mastercorg Github release actions

Installation

npm install @master/css.react

Required @master/css^2

Preparation

Let's say ./src/master.js is the file where you manage the Master CSS.

import MasterCSS from '@master/css'
import config from './master.css'
export const css = new MasterCSS({ config })

Hooks

useScheme

Hook css.scheme and css.theme changes.

import { useScheme, useRendered } from '@master/css.react'
import { useCallback } from 'react'
import { css } from './master'

export default function ThemeButton() {
    const { scheme, setScheme, theme } = useScheme(css)
    const changeScheme = useCallback(({ target }) => {
        setScheme(target.value)
    }, [setScheme])
    const effected = useEffected()
    return (
        <button className="rel">
            {effected && theme}
            <select value={scheme} onChange={changeScheme} className="abs full opacity:0 cursor:pointer" >
                <option value="light">☀️ Light</option>
                <option value="dark">🌜 Dark</option>
                <option value="system">System</option>
            </select>
        </button>
    )
}

Use setScheme to change the theme scheme for Master CSS.

useEffected

Hook side effects for binding document, window, localStorage, etc.

import { useScheme, useEffected } from '@master/css.react'

export default function ThemeButton({ onChange, className }: any) {
    const effected = useEffected()
    return (
        {effected && localStorage.getItem('scheme')}
    )
}

Often used to prevent server-side use of the browser API result in a hydration error.

useBreakpoints 🚧

import { useBreakpoints } from '@master/css.react'
import { css } from './master'

export default function Home() {
    const at = useBreakpoints(css)
    return (
        <>
            {at('>=md') && '>=1024'}
            {at('<=md') && '<=1024'}
            {at('>md') && '>1024'}
            {at('<md') && '<1024'}
            {at('=md') && '=1024'}
        </>
    )
}

NPM Version

Keywords

FAQs

Last updated on 05 Dec 2022

Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc