Skip to content

Commit a8dca34

Browse files
authored
feat: expose tokens in useTheme (#130)
1 parent 4ba7a2b commit a8dca34

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

src/kit/Theme/UI.tsx

+6-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import { StyleProvider } from '@ant-design/cssinjs';
22
import { theme as AntdTheme, App, ConfigProvider } from 'antd';
3+
import { GlobalToken } from 'antd/es/theme';
34
import React, { useContext, useEffect, useRef } from 'react';
45

56
import { globalCssVars, Theme, ThemeVariable } from './themeUtils';
@@ -28,6 +29,7 @@ const UIContext = React.createContext<ThemeSettings | undefined>(undefined);
2829
export const useTheme = (): {
2930
getThemeVar: (name: ThemeVariable) => string;
3031
themeSettings: ThemeSettings;
32+
tokens: GlobalToken;
3133
} => {
3234
/**
3335
* Some UI Kit components such as the CodeEditor do not inherit the theme from css or page styling
@@ -44,7 +46,10 @@ export const useTheme = (): {
4446
return context.theme[name];
4547
};
4648

47-
return { getThemeVar, themeSettings: context };
49+
const { useToken } = AntdTheme;
50+
const { token: tokens } = useToken();
51+
52+
return { getThemeVar, themeSettings: context, tokens };
4853
};
4954

5055
export const UIProvider: React.FC<{

0 commit comments

Comments
 (0)