Theme UI is a robust library for constructing themeable user interfaces, leveraging constraint-based design principles to build cohesive design systems, component libraries, and web applications. It serves as the spiritual successor and next evolution of Styled System, offering a flexible API designed for developer ergonomics. The current stable version is 0.17.4. While specific release cadences for major versions aren't fixed, the project sees active development with frequent minor and develop releases, indicating an ongoing commitment to bug fixes and incremental improvements on the 0.x branch. Key differentiators include its powerful `sx` prop for direct, theme-based styling, broad compatibility with virtually any UI component library, built-in support for dark modes, primitive page layout components, and deep integration with popular tools like Gatsby and MDX for content styling. It is built on Emotion for efficient scoped styles and adheres to a standard Theme Specification, promoting interoperability and a consistent design language across projects, making it ideal for large-scale design system implementation.
npm install theme-uiVerified import paths — ran on the pinned version, not inferred.
This quickstart demonstrates setting up a `ThemeProvider` with a custom theme and using basic components like `Box` and `Text` with the `sx` prop for styling, including responsive styles and dark mode support via theme configuration. This code is runnable in a React environment.
Ensure your entire application or at least the part utilizing Theme UI components is wrapped within `<ThemeProvider theme={yourTheme}>...</ThemeProvider>`.Prefer using `sx` for all your styling when working with Theme UI to leverage theme constraints and ensure consistent behavior. For custom, non-theme-driven styles, consider using Emotion's `css` prop or a dedicated component.
Consult the official Theme UI documentation and GitHub release notes before and after upgrading to identify any specific migration steps or API changes required for your codebase.
Upgrade your `react` and `@emotion/react` packages to satisfy the peer dependency requirements: `npm install react@^18.0.0 @emotion/react@^11.1.1`.
Wrap your root component or the section using Theme UI with `<ThemeProvider theme={yourTheme}>`.Ensure you have `@types/theme-ui` installed and that your `tsconfig.json` includes `theme-ui` types. You might also need to configure a custom `jsx` pragma in your `tsconfig.json` or Babel configuration.
Refactor your component to be a functional component or pass the theme down as props from a parent functional component that uses `useThemeUI`.