Theme Color Tokens
Part of the Fundamentals section of Coddy's Tailwind CSS journey. Lesson 46 of 55.
In Tailwind 4, @theme { --color-ink: #112233; } creates color utilities such as bg-ink and text-ink. An ink background computes to RGB 17, 34, 51. The color namespace tells Tailwind which utilities to generate.
<div class="bg-ink">Museum sample</div>@theme {
--color-ink: #112233;
--color-paper: #eeeeee;
--color-sea: #006677;
--color-sun: #ffcc00;
}Define theme variables at the top level of the local stylesheet after the Tailwind import. A normal custom property in a selector can hold a value, but it does not by itself define a new named Tailwind color utility.
Challenge
MediumDefine a theme color named accent with hexadecimal value #335577, and use it for the booking panel background.
Keep the supplied content and element IDs. Edit the HTML utility classes or the requested CSS. Click Run preview to refresh the preview after edits, then use Check/Run code to grade your work.
Try it yourself
<!doctype html>
<html lang="en"><head><meta charset="utf-8"><meta name="viewport" content="width=device-width,initial-scale=1"><title>Practice studio</title><link rel="stylesheet" href="./styles.css"></head><body>
<div id="target" class="">Booking panel</div>
</body></html>
This lesson includes a short quiz. Start the lesson to answer it and track your progress.
All lessons in Fundamentals
1Meet Tailwind
A Styled First RunChoosing UtilitiesCombining UtilitiesThe Local StylesheetRecap: Meet Tailwind7Sizing and Overflow
Element WidthElement HeightMaximum WidthOverflow BehaviorRecap: Sizing and Overflow10Theme and Dark Mode
Theme Color TokensTheme Spacing TokensTheme Radius TokensClass-Based Dark ModeRecap: Theme and Dark Mode