@chakra-ui/system
Version:
Chakra UI system primitives
1 lines • 956 B
Source Map (JSON)
{"version":3,"sources":["../src/use-theme.ts"],"sourcesContent":["import { WithCSSVar } from \"@chakra-ui/styled-system\"\nimport { Dict } from \"@chakra-ui/utils\"\nimport { ThemeContext } from \"@emotion/react\"\nimport { useContext } from \"react\"\n\n/**\n * `useTheme` is a custom hook used to get the theme object from context.\n *\n * @see Docs https://chakra-ui.com/docs/hooks/use-theme\n */\nexport function useTheme<T extends object = Dict>() {\n const theme = useContext(\n ThemeContext as unknown as React.Context<T | undefined>,\n )\n if (!theme) {\n throw Error(\n \"useTheme: `theme` is undefined. Seems you forgot to wrap your app in `<ChakraProvider />` or `<ThemeProvider />`\",\n )\n }\n\n return theme as WithCSSVar<T>\n}\n"],"mappings":";;;AAEA,SAAS,oBAAoB;AAC7B,SAAS,kBAAkB;AAOpB,SAAS,WAAoC;AAClD,QAAM,QAAQ;AAAA,IACZ;AAAA,EACF;AACA,MAAI,CAAC,OAAO;AACV,UAAM;AAAA,MACJ;AAAA,IACF;AAAA,EACF;AAEA,SAAO;AACT;","names":[]}