ant-design / antd-style

css-in-js library with antd v5 token system
https://ant-design.github.io/antd-style/
MIT License
187 stars 29 forks source link

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

Closed ByYogi closed 3 months ago

ByYogi commented 3 months ago

🥰 需求描述

我看使用方式基本上就是 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>
  );
arvinxx commented 3 months ago

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

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

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

ByYogi commented 3 months ago

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

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

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

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