Chakra UI v1.0 is focused on improving the ideas and concepts from v0.8 to make it even easier to create, theme and extend components.
While there are quite a number of new features we've added, we focused on making Chakra UI a stable base to build your own design systems on top of. In the end, we want make you feel more confident using Chakra UI in production.
Theming API: Chakra UI now provides a new theming API which makes it easy to style components and their modifiers (sizes, variants, and color scheme) from your theme.
Color mode improvement: We've fixed the bugs related to Color mode and made it possible to persist color mode, set initial color mode, and lock specific components to a certain color mode.
Better TypeScript support: This means all components have very good
TypeScript support and most low-level components like Box
, Flex
will support
the as
prop and types will be extracted properly.
Theme-aware sx prop: Just like theme-ui
, we've added support for the sx
prop to help you add theme-aware styles directly on any Chakra component. This
is useful if you're not a fan of style props, and prefer passing all styles in
one object.
Deprecated PseudoBox: We've removed PseudoBox
and merged all its props
with Box
so you can use pseudo style props, like _hover
, _active
in any
Chakra components.
Here's a list of steps to migrate your project to v1. Don't worry if your styles aren't exactly the same, this is to be expected and following these steps will fix it.
Install the framer-motion
package. We use this to manage animations and
transitions within components.
Remove the emotion-theming
package. As at emotion v11, emotion-theming
as
been removed and all it's functionality as been migrated to @emotion/react
.
Rename the @emotion/core
package to @emotion/react
. @emotion/core
was
recently changed to @emotion/react
following the v11 release by the emotionjs
team.
Rename the @chakra-ui/core
package to @chakra-ui/react
.
Please note that when using Chakra UI in a TypeScript project, a minimum TypeScript version of
3.8.0
is required.
Chakra moved all icons to a separate package @chakra-ui/icons
. We recommend
using react-icons
in your projects considering it has a robust set of icons.
However, you can still install this package.
Swap out ThemeProvider
with ChakraProvider
to make setup cleaner.
ChakraProvider
adds the following providers for you automatically:
theme.styles.global
to your application.Optionally via prop:
CSSReset
, pass resetCSS={false}
.z-index
in your application. Pass the portalZIndex
prop.Fire up your "Find and Replace" tool in VSCode or IntelliJ. Find variantColor
and replace with colorScheme
.
Reason: We renamed this prop to make it easier to understand that this prop represents a visual color scheme, not a css color attribute.
size
prop#Change size
prop to width
or w
and height
, or h
. If you'd like to use
only one prop to manage this, you can rename it to boxSize
.
We strongly recommend using the width
and height
props
Reason: We think the
size
prop should only be used for component size modifiers. Thesize
prop has caused a lot of confusion in the past because, in some components (e.g. Button), it means the visual size and in others (e.g Box), it means width and height.
PseudoBox
is now deprecated and its props can now be directly applied to
Box
. Replace all PseudoBox
components with Box
.
Callout
is now deprecated and you can use an Alert
instead.
You may skip this if you didn't customize your breakpoints.
To provide easier extensibility and typesafety, breakpoints should now be
created through createBreakpoints
by passing an object:
Please note that unless you plan overriding all components, sm
to xl
are
required.
You may of course add for example xxl
or other breakpoints in between -
createBreakpoints
will sort in ascending order. It is adviseable to not mix
css units.
Reason: Previously, breakpoints on a theme had to be an array with your breakpoints in ascending order which made it hard to reference which value was correlating to
md
etc. Also, you had to manually manipulate the array by defining properties on it, which was often overlooked and not typesafe.
You can skip this if you are not already using the color mode feature.
To keep color mode settings in sync across pages, add the ColorModeScript
.
For exhaustive examples, please visit Features > Color Mode # Add ColorModeScript.
We've updated the API of some components to fix bugs, improve usability, types and accessibility.
AccordionHeader
to AccordionButton
. This is to
remove the notion that it is a header when it is actually a button.WAI-ARIA guidelines require that accordion buttons be wrapped in the appropriate heading tag
h2-h6
based on the page heading flow.
We think the name AccordionHeader
might mislead users to think we handle this
out of the box when we don't. Here's how to handle this:
AccordionItem
in isolation, it must be used within
Accordion
.AspectRatioBox
to AspectRatio
.Removed support for the addSeparator
prop.
leftIcon
or rightIcon
to the equivalent icon
React element.Replacement logic: If
leftIcon
is<EmailIcon/>
from Chakra.
This reduces the effort needed to use custom icons, eliminates TypeScript errors, and reduces unused icons bloating your app.
Renamed variantColor
to colorScheme
Removed negative side margins on leftIcon
and rightIcon
elements. We
believe the user should handle these side margins.
#1024
variantColor
to colorScheme
Deprecated the isFullWidth
prop. Checkbox
now takes up the width of its
parent by default.
To allow for better checkbox group layout, the CheckboxGroup
component no
longer supports every style prop.
You can now only pass size
, variant
, and colorScheme
in addition to
CheckboxGroup
-specific props (value
, defaultValue
, and onChange
).
We believe a checkbox group's layout should be managed by your design requirements. The checkboxes can be grouped using
Stack
, placed in a grid usingSimpleGrid
or made to wrap automatically usingWrap
.
Color mode now persists correctly when you refresh the page. All you need to
do is add ColorModeScript
script as the first child of body
.
Here's how to add it for Next.js:
Here's how to add it for Gatsby:
gatsby-plugin-chakra-ui
to
@chakra-ui/gatsby-plugin
. Please make sure to have updated this when
installing Chakra UI in your next Gatsby project.You can also install the
@chakra-ui/gatsby-plugin
package which automatically configures ColorModeScript
along with
ChakraProvider
.
The onRequestEdit
prop has been renamed to onEdit
. This applies to both the
prop passed to Editable
as well as the prop in its render props.
Basic interface icons provided by Chakra have moved to the @chakra-ui/icons
package. Replace all <Icon name="..." />
elements imported from
@chakra-ui/react
with equivalent React elements imported from
@chakra-ui/icons
.
Replacement logic: If
<Icon name="search" />
is used, then replace it with<SearchIcon />
from Chakra icons package.
Existing icons will appear as a question mark until refactored.
theme
create your own icons using the createIcon
utility:As a convenience you can also import createIcon
from the icons
package along
with other icons:
icon
to the equivalent icon React element.Replacement logic: If
icon
is<EmailIcon/>
from Chakra.
This reduces the effort needed to use custom icons, eliminates TypeScript errors, and reduces unused icons bloating your app.
variantColor
to colorScheme
.Renamed colorStart
and colorEnd
props to startColor
and endColor
respectively.
Resolved SSR issue with Next.js. If you still run into issues, we recommend
using the Img
component which is a regular img
tag with support for Chakra
props.
When using InputAddon
, you no longer need to pass border radius properties to
the Input
. InputGroup
will intelligently detect the addon and apply the
necessary border to the input.
Due to accessibility reasons, we've deprecated the isDisabled
prop for Link
.
Renamed stylePos
to stylePosition
isReversed
props in
favor of the direction
prop.direction
and spacing
props.MenuList
component,
should now be passed to Menu
.placement
prop has moved from MenuList
to Menu
.Removed addAriaLabels
and formatIds
props in favor of passing a top-level
id
prop to the modal.
Removed preserveScrollBarGap
prop. We preserve scroll bar gap by default to
prevent any layout shift.
Only pass size
values defined in the components theme. Hard-coded values
will be ignored. Update the styles in theme.components.Modal
to reflect your
custom values.
You can now disable focus trap by passing trapFocus={false}
.
Modal comes with preset transitions to make it easy for you. You can remove
any existing Scale
, ScaleFade
or SlideFade
components.
Changed color
prop to colorScheme
.
trackColor
prop now takes a specific theme color or a valid css
color.thickness
prop to point to an actual thickness value in px
(e.g. thickness={4}
)variantColor
prop to colorScheme
.Deprecated the isFullWidth
prop. The Radio
takes up the width of its
parent by default.
Deprecated the RadioButton
component. Use the useRadio
hook to create
custom radio buttons. Learn more about
creating custom radio buttons.
The useRadio
hook is exported with state and focus management logic for use
in creating tailor-made radio component for your application
Deprecated the isFullWidth
prop. The RadioGroup
takes up the width of the
parent by default.
Deprecated the RadioButtonGroup
component. Use the useRadioGroup
hook to
control a group of custom radio buttons. Learn more about
creating custom radio buttons.
To allow for better Radio group layout, the RadioGroup
component no longer
supports every style prop. You can only pass size
, variant
, and
colorScheme
in addition to RadioGroup
props (value
, defaultValue
, and
onChange
).
SliderFilledTrack
with SliderTrack
.Rename the color
prop to colorScheme
.
Change variantColor
prop to colorScheme
.
variantColor
to colorScheme
.isDisabled
prop on the TagCloseButton
component.lg
to md
.react-spring
dependency in favor of framer-motion
.toast.isActive
method.toast.close
or toast.closeAll
methods.toast.update
method.onCloseComplete
prop, which is a callback function that is
invoked when the toast closes.rc
versions)#Wrap
must now be wrapped in WrapItem
. This makes it easy to
customize the WrapItem
using the sx
prop.All transition components like Collapse
, Fade
, SlideFade
, etc. use the
in
prop to trigger its transition/animation, instead of isOpen
. Change the
isOpen
prop to in
config
prop, in favor of adding global styles to
theme.styles.global
.focus-visible
package.useDisclosure
now accepts object
instead of boolean
as initial values.That's it! Welcome to Chakra UI v1 🥳.
If you still experience issues after migrating, feel free to create an issue or join our Discord chat here: https://discord.gg/dQHfcWF