Skip to content

[v4] "Cannot read properties of null (reading '50')" when using theme.extend.colors.zinc: null #16035

Closed
@tordans

Description

@tordans

What version of Tailwind CSS are you using?

"tailwindcss": "^4.0.1","@tailwindcss/vite": "^4.0.1",

What build tool (or framework if it abstracts the build tool) are you using?

Astro

What version of Node.js are you using?

v22.13.1 (npm v10.9.2)

What browser are you using?

Chrome

What operating system are you using?

macOS

Describe your issue

Tailwind 4 chokes when colors are set to null in the JS config.

I used to have code like this in my config to force only one color of gray and disable the autocomplete and class generation for all other colors:

  theme: {
    extend: {
      colors: {
        gray: colors.stone,
        slate: null,
        zinc: null,
        neutral: null,
        stone: null,
      },
    },
  },

With those settings I am getting errors like

07:13:33 [ERROR] Cannot read properties of null (reading '50')
  Stack trace:
    at /Users/…/Development/…/src/layouts/base.css
    [...] See full stack trace in the browser, or rerun with --verbose.

This error shows when using the npx @tailwindcss/upgrade@next as well as when I update manually (referencing the js config from the css file) and use the vite Plugin in Astro.


I see the new way to disable default colors is https://tailwindcss.com/docs/colors#disabling-default-colors which does work once I remove the null lines from my js config.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions