Migration Guides
v0.9
Dropped support for legacy browsers.
Theme UI packages became lighter! Built source code is now 9.5 kB (34%) smaller.
The trade-off is, Babel config has changed and it no longer supports Internet Explorer 11. If you need to support legacy browsers, you can transpile node_modules (e.g. with next-transpile-modules).
- See build raport with size comparison for each package
- Inspect updated Babel config
- Visit Bundlephobia
Internal package gatsby-theme-code-recipes was removed.
v0.8
Theme configuration options were moved to theme.config object.
Deprecations:
useRootStyles,useCustomProperties,useColorSchemeMediaQuery,useBorderBox, anduseLocalStorageoptions on the theme object are now scoped under aconfigobject on the theme, and the root-level options, now deprecated, will be removed in a future release.(e.g. you should be setting
theme.config.useBorderBoxinstead oftheme.useBorderBox)- ⚠ All config options should be migrated at once. If Theme UI sees
theme.configexists, it won't look for options on thetheme.
- ⚠ All config options should be migrated at once. If Theme UI sees
APIs deprecated in v0.6 were removed.
theme.useBodyStyles⟶theme.config.useRootStylesStyled⟶Themed
Following the deprecation of useBodyStyles, useRootStyles now defaults to
true. This means that your styles from theme.styles.root are now applied to
<html> element, not <body> element. Most use cases should be fine, but some
styles may need adjustment.
v0.6
What's New
Styledcomponents dict was renamed toThemedto avoid confusion withstyledcomponents constructors from@emotion/styledand similar libraries.theme.useRootStylesconfiguration option (false by default). Set it totrueto addstyles.roottohtmlinstead ofbody.theme.useBodyStylesconfiguration option still defaults totrue, but it's going in to be deprecated in favor oftheme.useRootStylesin the future.
New scale:
transitionssupportingtransitionCSS property. Issue #1079, PR #1272Objects in nested scales can now have a
__defaultkey. PR #951Given the theme
const theme = {colors: {primary: {__default: '#00f',light: '#33f',}}}color: 'primary'resolves tocolor: '#00f'.Configuration option for printing color mode. PR #1267, issue #1144. No more wasted ink.
{initialColorModeName: "dark",printColorModeName: "light"}A new component, Paragraph was added in PR #1298
Breaking Changes
Theme UI 0.6 depends on Emotion 11, and isn't compatible with Emotion 10 anymore.
- If you didn't install Emotion separately, this update shouldn't affect you.
- If your other dependencies depend on Emotion 10, and have no published versions for Emotion 11, you can use Yarn resolutions or Webpack's resolve.alias to enforce a version.
Refer to Emotion 11 release notes for more information.
Color mode flash on first render is gone, but to achieve this we had to bring back
theme.rawColors.- You can no longer read raw color values from
theme.colorswhen reading theme fromuseThemeUIor insidesx. .colorsobject contains Custom CSS Properties now.- If you need to pass original value somewhere where CSS Properties (e.g.
WebGL Canvas) won't work use
.rawColors.
How to migrate?
Find places where you read
colorsfrom the useThemeUI and extractrawColorsinstead ofcolors.const { rawColors: colors } = useThemeUI().theme- You can no longer read raw color values from
Default color mode name is no longer
"default"— it's nowundefined, what represents the lack of color mode set by user or detected from preferences.useColorSchemeMediaQuerydefaults totrue. Issue #624, PR #1373How to migrate? Add
useColorSchemeMediaQuery: falseto your theme if you don't have this property. Read more in the docs.We no longer export internal React context named as
Context😅 It wasn't and it's still not public API, but if you used it and you really need it, you can grab it as__ThemeUIContext. (But please don't do this. UseThemeProviderfrom @theme-ui/core for local theme overrides instead.)
Deprecations
Styledwill be removed in v0.7. UseThemedinstead.useBodyStyleswill be removed in v0.7. UseuseRootStylesinstead.
TypeScript Changes
Theme UI is now written in TypeScript, and the emitted types differ from
@types/theme-ui.
falsein now accepted in responsive tuple types. PR #1499Known colors (primary, text, background, accent, secondary) in
ColorModecan now be nested scales.The following no longer typechecks, as
colors.primarycan be an object.sx={{color: theme => theme.colors?.primary?.toUpperCase()}}But the following code still works.
sx={{color: theme => theme.colors?.primary}}If
colors.primaryis an object,colors.primary.__defaultis used.falsevalues are skipped before passing style objects to Emotion. Issue #1297, PR #1460.The following syntax is now supported
sx={{ color: isActive && blue }}"as" prop on Themed.X components now properly opts out of typechecking
- TypeScript users, don't use
ComponentProps<typeof Themed['div']>, importThemedComponentand useThemedComponent<'div'>instead.
- TypeScript users, don't use
Theme UI 0.6 depends on
csstypev3 instead ofcsstypev2.Renamed types
- Anything copied from
styled-systemtypes was renamed or removed. SxPropswas renamed toSxProp.SxStyleProp, an alias forThemeUIStyleObjectwas removed. UseThemeUIStyleObjectinstead.
- Anything copied from
Refer to the changelog for a full list of changes.
v0.3
What's New
- Components can now be imported directly from the
theme-uipackage. Be sure that treeshaking is enabled with your build tool. - Includes smart defaults for adding base styles to the
<body>element. - Simplified color modes API.
- New
@theme-ui/css,@theme-ui/core,@theme-ui/color-modes, and@theme-ui/mdxpackages allow for more bespoke ways to use the library.
Breaking Changes
@emotion/reactand@mdx-js/reactare now dependencies oftheme-uiand should not be installed separately. If you'd like to use a particular version of each library, use Yarn resolutions.- Theme UI context no longer provides
context.components. If you're using this object from context, use the MDX hook instead. E.g.import { useMDXComponents } from '@mdx-js/react' - If you'd like color mode to be initialized from the
prefers-color-schememedia query, you must enable theuseColorSchemeMediaQuery: trueflag in your theme. - The
ColorModecomponent is deprecated and no longer required to add color styles to the<body>element. - The following components have been removed in favor of using
BoxandFlexcomponents:Layout,Header,Main,Footer - The
initialColorModeflag no longer works, useinitialColorModeNameinstead. - The
ThemeProvidernow adds global typographic styles to the<body>element based ontheme.styles.root. To disable this behavior set theuseBodyStyles: falseflag in your theme. - Theme context is now stateless. If you've made use of
context.setTheme, this no longer works. An alternative approach is available with the@theme-ui/editorpackage. - The
ThemeStateProvidercomponent is no longer avialable, see@theme-ui/editoras an alternative. - The
@theme-ui/editorpackage has a completely new API. Please refer to the package's README.md for more information.
v0.2
JSX Pragma
If you were using the Theme UI custom JSX pragma, rename the css prop to sx.
This does not apply if you were importing and using the css utility function
manually.
theme-ui-typography
If you were using the theme-ui-typography package, install the new package
named @theme-ui/typography instead. The toStyle API is no longer included.
Use the toTheme API instead, see the
Typography.js docs for how to use this utility.
Box and layout component
If you were using Styled System style props on the Box component or any other
layout component, replace these props with either the sx prop or
by using the css utility.
Other
- Replace
ColorModeProviderandComponentProviderwith theThemeProvidercomponent. - The
@emotion/styledpackage is no longer required for Theme UI. If you are not using it directly in your application, you can remove it from your dependencies.