【发布时间】:2021-11-19 22:15:10
【问题描述】:
我在 Chakra UI 上使用 extendTheme() 为 React 设置了默认主题。
当我尝试像这样更改 Select 组件的样式时,_focus 样式不适用,而 color 的行为符合预期。
参考
字幕
代码
index.ts
import { extendTheme } from '@chakra-ui/react';
import { Select } from './select';
export const theme = extendTheme({
colors: {
brand: '#008561',
brandLight: '#00b485',
},
components: {
Select,
},
});
选择.ts
export const Select = {
parts: ['field'],
baseStyle: ({ colorMode }: any) => ({
field: {
color: 'brandLight',
_focus: {
borderColor: colorMode === 'dark' ? 'brandLight' : 'brand',
},
},
}),
sizes: {},
variants: {},
defaultProps: {},
};
【问题讨论】:
标签: javascript reactjs chakra-ui