I want to customize the styles of some antd components written in cssinjs.
I created a HOC component to access the theme and override some styles and call it after defining the providers
import { useToken, useStyleRegister } from 'antd/es/theme/internal'
import { prefixCls } from 'Src/constants'
import { ReactNode } from 'react'
import { CSSObject } from '@ant-design/cssinjs'
import { GlobalToken } from 'antd/es/theme/interface'
function getStyleButton(token: GlobalToken): CSSObject {
return {
[`.${prefixCls}-btn`]: {
['&-default']: {
backgroundColor: 'transparent '
}
}
}
}
export const OverloadStyle = (props: { children: ReactNode }) => {
const [theme, token, hashId] = useToken()
useStyleRegister(
{
theme,
token,
hashId,
path: ['OverloadStyle']
},
() => [
getStyleButton(token),
]
)
return <>{props.children}</>
}
but there was a problem with style priority
calling !important is not the best way
how to make those styles which I define were below? Or are there other more convenient ways to extend the standard styles?