ant-design / antd-style

css-in-js library with antd v5 token system

Home Page:https://ant-design.github.io/antd-style/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

👑 [需求]能不能出一个更简短创建css样式的api

ByYogi opened this issue · comments

commented

🥰 需求描述

我看使用方式基本上就是 createStyles
获取类名好繁琐。 要useStyle,又要调用.styles 还有调用里面具体的某个key

我想能不能直接就返回css样式。调用就直接获取该属性名

const useStyle = createStyles(({ token }) => {
    return {
      root: {
        color: token.colorText,
        ':hover': {
          color: token.colorLink,
        },
      },
    };
  });
  return (
    <a className={useStyle().styles.root} {...props}>
      {props.children}
    </a>
  );

你应该可以直接用 css 试试:

import { css } from 'antd-style';
const style = css`....`

但这种方法就是没有动态性,然后会比较碎一些

commented

你应该可以直接用 css 试试:

import { css } from 'antd-style';
const style = css`....`

但这种方法就是没有动态性,然后会比较碎一些

只有createStylescss 两种方式吗,了解了