@theme-ui/core package provides minimal React support for lightweight usage of Theme UI. It includes the essential features for styling React components with the sx prop and accessing theme values.
Installation
When to Use
Use@theme-ui/core when you:
- Want a minimal, lightweight version of Theme UI
- Don’t need the full component library
- Are building your own component library on top of Theme UI
- Want to minimize bundle size
theme-ui package, you don’t need to install @theme-ui/core separately—it’s already included and re-exported.
Exports
Components
ThemeProvider
A React context provider that makes your theme available to all components.
theme:Theme | ((outerTheme: Theme) => Theme)- Your theme object or a function that receives the outer theme and returns a new themechildren:React.ReactNode- Child components
Hooks
useThemeUI
A hook to access the current theme and Theme UI context.
__EMOTION_VERSION__:string- The version of Emotion being usedtheme:Theme- The current theme objectcolorMode:string(when using ColorModeProvider) - The current color modesetColorMode:Function(when using ColorModeProvider) - Function to change color mode
Utilities
merge
Deeply merges theme objects together.
JSX Runtime
jsx
The JSX function that creates React elements with support for the sx prop.
createElement
An alias for jsx for Babel JSX pragma support.
Entry Points
Main Entry Point
/jsx-runtime
For the new JSX transform:
jsxjsxs
/jsx-dev-runtime
Development version of the JSX runtime:
jsxDEV
TypeScript Types
All types from@theme-ui/css are re-exported:
Notes
@theme-ui/coredoes not add global styles to<html>or<body>. For global styles, see the Global Styles guide.- Requires
@emotion/reactas a peer dependency - Requires React 18 or higher
- No side effects - safe for tree-shaking
Related
- @theme-ui/css - Framework-agnostic styling utilities
- @theme-ui/components - Pre-built UI components
- @theme-ui/color-modes - Color mode utilities
