diff --git a/components/layout/Sider.tsx b/components/layout/Sider.tsx index b149884102..6f91833a8a 100644 --- a/components/layout/Sider.tsx +++ b/components/layout/Sider.tsx @@ -9,6 +9,7 @@ import omit from 'rc-util/lib/omit'; import isNumeric from '../_util/isNumeric'; import { ConfigContext } from '../config-provider'; import { LayoutContext } from './context'; +import useStyle from './style/sider'; const dimensionMaxMap = { xs: '479.98px', @@ -97,6 +98,12 @@ const Sider = React.forwardRef((props, ref) => { onCollapse?.(value, type); }; + // =========================== Prefix =========================== + const { getPrefixCls } = useContext(ConfigContext); + const prefixCls = getPrefixCls('layout-sider', customizePrefixCls); + + const [wrapCSSVar, hashId, cssVarCls] = useStyle(prefixCls); + // ========================= Responsive ========================= const responsiveHandlerRef = useRef<(mql: MediaQueryListEvent | MediaQueryList) => void>(); responsiveHandlerRef.current = (mql: MediaQueryListEvent | MediaQueryList) => { @@ -145,10 +152,7 @@ const Sider = React.forwardRef((props, ref) => { handleSetCollapsed(!collapsed, 'clickTrigger'); }; - const { getPrefixCls } = useContext(ConfigContext); - const renderSider = () => { - const prefixCls = getPrefixCls('layout-sider', customizePrefixCls); const divProps = omit(otherProps, ['collapsed']); const rawWidth = collapsed ? collapsedWidth : width; // use "px" as fallback unit for width @@ -200,6 +204,8 @@ const Sider = React.forwardRef((props, ref) => { [`${prefixCls}-zero-width`]: parseFloat(siderWidth) === 0, }, className, + hashId, + cssVarCls, ); return (