79511052

Date: 2025-03-15 11:35:04
Score: 1
Natty:
Report link

In Tailwind CSS v4, you can add custom colours while keeping the default ones by using the @theme directive. Note that Tailwind exposes colours as CSS variables, so you must use the --color- prefix .

In css file

@import "tailwindcss";
@theme {
  --color-custom-yellow-500: #EDAE0A;
}

Using the Custom Colour in a React

function MyComponent() {
  return (
    <div className="bg-custom-yellow-500">
      Custom Yellow Background
    </div>
  );
}

For more details, visit the Official Docs

Reasons:
  • Has code block (-0.5):
  • User mentioned (1): @theme
  • Low reputation (0.5):
Posted by: Aatmik