Hardware FixRecommendedDevice not working? Your driver may be the problemCheck updates for common hardware issues.Fix DriversHalloween DealsAmazon USHalloween week deals: useful picks before month-endAmazon US: current deals, useful picks and tech finds.Check DealsClean PCRecommendedOne scan can reveal what keeps slowing WindowsLook for cleanup and repair opportunities.Run Scan×
Skip to content
World desk5 min

Stop Overriding Ant Design CSS: Tokens vs zeroRuntime in Ant Design 6

Tokens and zeroRuntime do different jobs in Ant Design 6. Tokens change theme values, while zeroRuntime turns off runtime style generation and requires a precompiled CSS import. Here is how to use both correctly.
Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Tokens and zeroRuntime are often mentioned together, but they do different jobs. Design tokens change the theme values Ant Design uses: colors, sizing, algorithms, and component-level values. zeroRuntime changes how component CSS reaches the browser. It turns off runtime style generation and asks you to import a precompiled stylesheet. In Ant Design 6, the practical answer is to make supported design changes through the theme API, and to use zeroRuntime when you want precompiled component styles. Enabling zeroRuntime does not replace token configuration, so it is not a shortcut around customization.

Tokens and zeroRuntime solve different problems

Most of the confusion in the title comes from treating these as one feature. The table below separates them.

As an Amazon Associate I earn from qualifying purchases.

Question Design tokens zeroRuntime
What it controls Theme values: global tokens, preset algorithms, and component tokens How component styles are supplied: generated at runtime, or precompiled CSS
Where it is set The theme property of ConfigProvider The theme property of ConfigProvider, plus an explicit stylesheet import
Changes the visual design? Yes, for the design changes the theme API supports Not by itself; it changes delivery of the component styles
Replaces CSS overrides? Covers supported design changes; custom CSS is still needed for anything outside the theme API Not stated as a replacement for overrides in the official theme documentation

What zeroRuntime does

Ant Design’s theme documentation states that zeroRuntime was added in version 6.0.0. It prevents runtime style generation and requires an additional CSS import. The documented full-stylesheet setup has two parts: import the complete stylesheet, import 'antd/dist/antd.css';, and set theme={{ zeroRuntime: true }} on ConfigProvider.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

The documentation says the full stylesheet includes all Ant Design component styles and does not include hashed class names. The official guide describes the mode this way: “Starting from 6.0.0, we provide zeroRuntime mode to further improve application performance.” That is the documented intent. The official material does not provide a measured performance result, so this article does not claim a speed or bundle-size gain.

Configure tokens first

Before changing how styles are delivered, check whether the design change is already covered by the theme API. Work through the levels in this order:

  1. Global token. Change a shared value such as the primary color through token in the theme property of ConfigProvider.
  2. Preset algorithm. If you want a different overall look, such as a dark theme, apply an algorithm through the same theme property.
  3. Component token. If one component needs a different value, use the components key inside the same theme configuration for that component’s tokens.
<ConfigProvider
  theme={{
    token: { colorPrimary: '#1677ff' },
    components: { Button: { /* component tokens */ } },
  }}
>
  <App />
</ConfigProvider>

Only fall back to CSS overrides for changes that the theme API does not express. Overrides aimed at internal component markup are the most fragile option, as covered in the migration section below.

Choose a style-delivery path

The official guidance offers two ways to supply component styles when you use zeroRuntime. The table compares them on the points that matter in a real project.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
Factor Full precompiled stylesheet Static styles via @ant-design/static-style-extract
Style coverage All component styles Selected components, chosen through the package’s includes option
Fit with configuration changes Documented as the default path; may be unsuitable when the project changes configuration, such as a custom prefix Documented for cases where the full stylesheet is unsuitable, including configuration changes such as a custom prefix
Integration effort Import one stylesheet and enable zeroRuntime Generate the static file and make sure it is included in the application build
Bundle size or runtime speed Not stated; no measured comparison in the official documentation Not stated; no measured comparison in the official documentation

Set up zeroRuntime step by step

  1. Confirm that your project is on Ant Design 6 and that React is version 18 or later.
  2. Import the full stylesheet once, in your application entry file: import 'antd/dist/antd.css';.
  3. Set zeroRuntime: true in the theme property of ConfigProvider.
  4. Keep your token and component-token configuration in place. Enabling zeroRuntime does not remove it.
  5. If the full stylesheet is too broad, or your project changes configuration such as a custom prefix, evaluate @ant-design/static-style-extract and include the generated file in your build.
  6. If you also use the @layer mechanism, place the stylesheet inside the matching layer (see below).

Upgrading from Ant Design 5

The official v5-to-v6 migration guide covers the following points. Check the current guide before upgrading, since version requirements change over time.

  • React: Ant Design 6 requires React 18 or later.
  • Browsers: Internet Explorer is no longer supported. Check your browser support matrix against your audience.
  • CSS variables: Ant Design 6 uses CSS variables by default, so custom CSS that depends on the older output should be tested.
  • Icons: Update the icons package as the migration guide directs.
  • Internal DOM: Component DOM changes can break custom selectors that target internal nodes. Review every selector that reaches into component internals.
  • Migration checks: The guide recommends the Ant Design CLI to find deprecated APIs, component usage, and version differences.

Using zeroRuntime with @layer

Ant Design’s compatibility guide documents @layer support from version 5.17.0. It is a way to lower the priority of Ant Design’s styles so your own CSS wins without raising selector specificity. When you combine this with zeroRuntime, the precompiled standalone stylesheet must be imported into the same layer. The guide’s example is:

@import url(antd.css) layer(antd);

Two rules keep the cascade predictable. Set the layer order on purpose, so the Ant Design layer sits where you expect relative to your own layers. Assign your reset CSS to a layer consistently. An unlayered or mis-layered reset can override the lowered-priority Ant Design styles, which is the same problem the layer was meant to prevent.

Independent reader supportYour contribution helps us test, update, and keep practical guides available for everyone.Support on Ko-Fi

Troubleshooting

  • Components appear unstyled after enabling zeroRuntime. The full stylesheet import is missing, or the build does not include it. Confirm the import runs in the entry file and that the bundled CSS contains Ant Design rules.
  • Your overrides do not win when using @layer. The Ant Design stylesheet is outside its layer, the layer order is wrong, or the reset CSS is unlayered. Check each of these in that order.
  • The full stylesheet does not fit your setup. If you use a custom prefix or need only some components, the full stylesheet may be the wrong choice. Evaluate static style extraction instead.
  • Custom selectors broke after the v6 upgrade. Component DOM changed. Rewrite selectors to target documented tokens or public class hooks where possible, rather than internal nodes.

What is not established

The official documentation does not publish a measured performance number for zeroRuntime, a bundle-size comparison against runtime generation, or a benchmark for static extraction. If performance is your reason for switching, measure your own application before and after the change. The version numbers in this article are the ones stated in Ant Design’s documentation at the time of writing, and they should be checked against the current docs before you upgrade.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
Best Value
Sale
Ant: The Definitive Guide, 2nd Edition
  • Used Book in Good Condition

Product prices and availability are accurate as of the date/time indicated and are subject to change. Any price and availability information displayed on Amazon at the time of purchase will apply.

Leave a Reply

Your email address will not be published. Required fields are marked *

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

More from the Wire

  1. World desk4 min
    How to Spot an AI Voice Scam Before Sending MoneyDon’t rely on how a caller sounds. Pause, call back through a known number, and verify the emergency with another trusted person before sending money.
  2. Mountain View desk4 min
    Google’s SynthID Detector: How to Check AI-Generated Images, Video and AudioGoogle’s SynthID Detector looks for an embedded watermark in supported images, video and audio. Here is what its results do—and do not—show.
  3. Redmond desk20 min
    How to create a link to File or Folder in Windows 11Windows 11 gives you several ways to point to a file or folder without moving or duplicating it. You can create a desktop shortcut,…
Recommended PC Tool
Recommended PC Tool
Windows Errors? Fix Them Before They SpreadFree repair scan
Outdated Drivers Are Slowing You DownFree scan - exact matches

Two free Windows tools

One Free Minute Could Fix That PC

Before you go - each of these free tools takes about a minute and tackles what quietly slows a Windows PC down.

Special offer. View Outbyte info, uninstall instructions, EULA, and Privacy Policy.