Radix Themes
repository·main·Indexed 27 days ago
https://github.com/radix-ui/themesAn open-source component library optimized for fast development, easy maintenance, and accessibility. It provides a set of pre-styled, accessible components for building high-quality user interfaces, featuring layout components like Grid, Flex, and Box, as well as specialized components such as Dialog, TextField, and SegmentedControl.
What's inside Radix Themes
- Radix Themes is an open-source component library designed for fast development, easy maintenance, and accessibility. It provides a set of pre-styled, accessible components that can be used to build high-quality user interfaces.
Migrate Blockquote trim prop in v2.0.0
mainThetrimprop was removed from theBlockquotecomponent in version 2.0.0.Update CSS specificity and Tailwind compatibility in v2.0.0
mainIn version 2.0.0, CSS selector specificity was capped to improve compatibility with Tailwind CSS:
- Styling HTML elements: specificity capped at
0,1,0. - Styling pseudo-elements: specificity capped at
0,1,1.
[Upgrade guide] If you were relying on specific Radix Themes selector specificity quirks for your own styles, verify that your overrides still function correctly.
- Styling HTML elements: specificity capped at
Import Radix Themes styles
mainWhen using Radix Themes, you must import the CSS styles for the components to render correctly. Depending on your version, the import path has changed:
- For version 0.0.39 and later: Import from
@radix-ui/themes/styles.css. - For version 0.0.38 and earlier: Import from
@radix-ui/themes/index.css.
Note that older versions used
@radix-ui/react-themesas the source, but this has been consolidated into the@radix-ui/themespackage.- For version 0.0.39 and later: Import from
Update width and height props (v3.0.0)
mainIn version 3.0.0, the
widthandheightprops no longer map to the space scale. They now accept arbitrary CSS values (including responsive object syntax).Upgrade Guide: Replace space scale values with corresponding pixel values or CSS variables. For example,
width="9"should be changed towidth="64px"orwidth="var(--space-9)".Use standalone component entrypoints in @radix-ui/themes
mainStarting from version 3.2.0, you can import components from standalone entrypoints to potentially optimize your bundle. For single components, import them directly. For compound components, it is recommended to use namespaced imports.
import { AlertDialog } from '@radix-ui/themes/components/alert-dialog'; import { Box } from '@radix-ui/themes/components/box'; // We recommend using namespaced imports for compound components import * as CheckboxGroup from '@radix-ui/themes/components/checkbox-group';Migrate Tooltip multiline prop in v2.0.0
mainThe
multilineprop was removed from theTooltipcomponent in version 2.0.0.[Upgrade guide] To achieve the same effect, pass
style={{ maxWidth: 250 }}to yourTooltipelements.Configure Theme appearance and hydration
mainWhen setting the
appearanceprop on theThemecomponent todarkorlight, Radix Themes injects a script to set the theme class andcolor-schemeon thehtmlelement.To prevent hydration mismatch warnings in frameworks like Next.js, you must add
suppressHydrationWarningto your<html>element. This change was introduced in version 0.0.38.Additionally, in version 0.0.44, the
Themecomponent was updated to respect the theme class format on thehtmlelement when updating appearance.Migrate Checkbox, RadioGroup, and Switch sizes in v2.0.0
mainIn version 2.0.0, the size scales for
Checkbox,RadioGroup, andSwitchwere reworked.[Upgrade guide] If you were using explicit
sizeprops, update them as follows:- For
CheckboxandRadioGroup:- Rename
size="1"$\rightarrow$size="2" - Rename
size="2"$\rightarrow$size="3"
- Rename
- For
Switch:- Use
size="3"to match the previoussize="2"look.
- Use
- For
Import fine-grained CSS files (v3.0.0)
mainRadix Themes v3.0.0 exports individual CSS files to allow for fine-grained control over CSS precedence and bundle size:
tokens.csscomponents.cssutilities.csslayout.css(styles for Box, Flex, Grid, Container, Section)
You can also customize color imports by using
tokens/base.cssand importing specific colors fromtokens/colors/*.css(e.g.,tokens/colors/blue.css).Migrate TextField usage (v3.0.0)
mainIn version 3.0.0, the
TextField.Inputpart was removed to simplify prop forwarding.Upgrade Guide:
- If using
TextField.InputwithoutTextField.Root: Rename it toTextField.Root. - If using
TextField.InputinsideTextField.Root: Remove theInputpart and move its props directly ontoTextField.Root. - If using
TextField.Slotto the right of an input: Add theside="right"prop. (Note: If two slots are used within oneTextField, they are automatically positioned on different sides).
- If using
Migrate to dot notation for multi-part components (v3.0.0)
mainIn version 3.0.0, Radix Themes dropped named exports for multi-part components. You must now use dot notation to access component parts. This change also ensures reliable behavior in React Server Components.
Example: Instead of importing a specific part as a named export, use the parent component with dot notation, such as
Dialog.Root.