Skip to content

monako97/css

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

18 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

css

css in js

基于 emotionstylis 的 css in js

yarn add @moneko/css -S

在 web component 中使用

import { css } from '@moneko/css';

const style = css`
  :host {
    --color: red;
  }
  p {
    color: var(--color, red);
    
    & span {
        color: green;
    }
  }
`;

function Comp() {
  return (
    <>
      <style>{style}</style>
      <p>aaa</p>
      <slot />
    </>
  );
}

插入全局样式

import { injectGlobal } from '@moneko/css';

// 执行这段代码将样式插入到head中,返回一个消除函数
const flush = injectGlobal`
    body {
        color: red;
    }
`;

// 消除刚才插入的全局样式
flush();

Releases

No releases published

Packages

No packages published