Skip to content

Text Color

<https://www.tailwindcss.cn/docs/text-color>

用法

ClassProperties
text-inheritcolor: inherit;
text-currentcolor: currentColor;
text-transparentcolor: transparent;
text-blackcolor: rgb(0 0 0);
text-whitecolor: rgb(255 255 255);
text-slate-50color: rgb(248 250 252);
text-slate-100color: rgb(241 245 249);
text-slate-200color: rgb(226 232 240);
text-slate-300color: rgb(203 213 225);
text-slate-400color: rgb(148 163 184);
text-slate-500color: rgb(100 116 139);
text-slate-600color: rgb(71 85 105);
text-slate-700color: rgb(51 65 85);
text-slate-800color: rgb(30 41 59);
text-slate-900color: rgb(15 23 42);
text-slate-950color: rgb(2 6 23);
text-gray-50color: rgb(249 250 251);
text-gray-100color: rgb(243 244 246);
text-gray-200color: rgb(229 231 235);
text-gray-300color: rgb(209 213 219);
text-gray-400color: rgb(156 163 175);
text-gray-500color: rgb(107 114 128);
text-gray-600color: rgb(75 85 99);
text-gray-700color: rgb(55 65 81);
text-gray-800color: rgb(31 41 55);
text-gray-900color: rgb(17 24 39);
text-gray-950color: rgb(3 7 18);

每种类别设定也是 从 50、100 一直到 950,由浅到深一般地,50 最浅,用作 hover 100 就合适了,500 基本为单词字面意义的颜色,再往上就很深了

名称颜色类别备注
text-zinc-200color: rgb(228 228 231);-
text-zinc-700color: rgb(63 63 70);-
text-neutral-200color: rgb(229 229 229);中性色
text-neutral-700color: rgb(64 64 64);中性色
text-red-200color: rgb(254 202 202);浅红
text-red-500color: rgb(239 68 68);
text-orange-200color: rgb(254 215 170);浅橙
text-orange-500color: rgb(249 115 22);橙色
text-amber-200color: rgb(253 230 138);琥珀 - 黄
text-amber-500color: rgb(245 158 11);琥珀 - 黄
text-yellow-200color: rgb(254 240 138);
text-yellow-500color: rgb(234 179 8);
text-lime-200color: rgb(217 249 157);酸橙 - 绿
text-lime-500color: rgb(132 204 22);酸橙 - 绿
text-green-200color: rgb(187 247 208);绿
text-green-500color: rgb(34 197 94);绿
text-emerald-200color: rgb(167 243 208);翠绿
text-emerald-500color: rgb(16 185 129);翠绿
text-teal-200color: rgb(153 246 228);青色
text-teal-500color: rgb(20 184 166);青色
text-cyan-200color: rgb(165 243 252);青蓝
text-cyan-500color: rgb(6 182 212);青蓝
text-sky-200color: rgb(186 230 253);天空蓝
text-sky-500color: rgb(14 165 233);天空蓝
text-blue-200color: rgb(191 219 254);
text-blue-500color: rgb(59 130 246);
text-indigo-200color: rgb(199 210 254);靛青
text-indigo-500color: rgb(99 102 241);靛青
text-violet-200color: rgb(221 214 254);紫色
text-violet-500color: rgb(139 92 246);紫色
text-purple-200color: rgb(233 213 255);紫色
text-purple-500color: rgb(168 85 247);紫色
text-fuchsia-200color: rgb(245 208 254);紫红色
text-fuchsia-500color: rgb(217 70 239);紫红色
text-pink-200color: rgb(251 207 232);粉色
text-pink-500color: rgb(236 72 153);粉色
text-rose-200color: rgb(254 205 211);玫瑰红
text-rose-500color: rgb(244 63 94);玫瑰红

设置文本颜色

使用 text-{color} 实用程序控制元素的文本颜色。

html
&lt;p class="text-blue-600">The quick brown fox...&lt;/p>

改变不透明度

使用颜色不透明度修改器控制元素文本颜色的不透明度。

html
&lt;p class="text-blue-600/100">The quick brown fox...&lt;/p>
&lt;p class="text-blue-600/75">The quick brown fox...&lt;/p>
&lt;p class="text-blue-600/50">The quick brown fox...&lt;/p>
&lt;p class="text-blue-600/25">The quick brown fox...&lt;/p>
&lt;p class="text-blue-600/0">The quick brown fox...&lt;/p>

悬停、焦点和其他状态

Tailwind 允许您使用变体修饰符有条件地在不同状态下应用实用程序类。例如,使用hover:text-blue-600 仅在悬停时应用text-blue-600 实用程序。

html
&lt;p class="text-slate-500 hover:text-blue-600">The quick brown fox...&lt;/p>

共 20 个模块,1301 篇 Markdown 文档。