返回介绍

Text Decoration Color

发布于 2024-07-30 22:16:06 字数 109785 浏览 0 评论 0 收藏 0

Utilities for controlling the color of text decorations.

Quick reference

ClassProperties
decoration-inherittext-decoration-color: inherit;
decoration-currenttext-decoration-color: currentColor;
decoration-transparenttext-decoration-color: transparent;
decoration-blacktext-decoration-color: #000;
decoration-whitetext-decoration-color: #fff;
decoration-slate-50text-decoration-color: #f8fafc;
decoration-slate-100text-decoration-color: #f1f5f9;
decoration-slate-200text-decoration-color: #e2e8f0;
decoration-slate-300text-decoration-color: #cbd5e1;
decoration-slate-400text-decoration-color: #94a3b8;
decoration-slate-500text-decoration-color: #64748b;
decoration-slate-600text-decoration-color: #475569;
decoration-slate-700text-decoration-color: #334155;
decoration-slate-800text-decoration-color: #1e293b;
decoration-slate-900text-decoration-color: #0f172a;
decoration-slate-950text-decoration-color: #020617;
decoration-gray-50text-decoration-color: #f9fafb;
decoration-gray-100text-decoration-color: #f3f4f6;
decoration-gray-200text-decoration-color: #e5e7eb;
decoration-gray-300text-decoration-color: #d1d5db;
decoration-gray-400text-decoration-color: #9ca3af;
decoration-gray-500text-decoration-color: #6b7280;
decoration-gray-600text-decoration-color: #4b5563;
decoration-gray-700text-decoration-color: #374151;
decoration-gray-800text-decoration-color: #1f2937;
decoration-gray-900text-decoration-color: #111827;
decoration-gray-950text-decoration-color: #030712;
decoration-zinc-50text-decoration-color: #fafafa;
decoration-zinc-100text-decoration-color: #f4f4f5;
decoration-zinc-200text-decoration-color: #e4e4e7;
decoration-zinc-300text-decoration-color: #d4d4d8;
decoration-zinc-400text-decoration-color: #a1a1aa;
decoration-zinc-500text-decoration-color: #71717a;
decoration-zinc-600text-decoration-color: #52525b;
decoration-zinc-700text-decoration-color: #3f3f46;
decoration-zinc-800text-decoration-color: #27272a;
decoration-zinc-900text-decoration-color: #18181b;
decoration-zinc-950text-decoration-color: #09090b;
decoration-neutral-50text-decoration-color: #fafafa;
decoration-neutral-100text-decoration-color: #f5f5f5;
decoration-neutral-200text-decoration-color: #e5e5e5;
decoration-neutral-300text-decoration-color: #d4d4d4;
decoration-neutral-400text-decoration-color: #a3a3a3;
decoration-neutral-500text-decoration-color: #737373;
decoration-neutral-600text-decoration-color: #525252;
decoration-neutral-700text-decoration-color: #404040;
decoration-neutral-800text-decoration-color: #262626;
decoration-neutral-900text-decoration-color: #171717;
decoration-neutral-950text-decoration-color: #0a0a0a;
decoration-stone-50text-decoration-color: #fafaf9;
decoration-stone-100text-decoration-color: #f5f5f4;
decoration-stone-200text-decoration-color: #e7e5e4;
decoration-stone-300text-decoration-color: #d6d3d1;
decoration-stone-400text-decoration-color: #a8a29e;
decoration-stone-500text-decoration-color: #78716c;
decoration-stone-600text-decoration-color: #57534e;
decoration-stone-700text-decoration-color: #44403c;
decoration-stone-800text-decoration-color: #292524;
decoration-stone-900text-decoration-color: #1c1917;
decoration-stone-950text-decoration-color: #0c0a09;
decoration-red-50text-decoration-color: #fef2f2;
decoration-red-100text-decoration-color: #fee2e2;
decoration-red-200text-decoration-color: #fecaca;
decoration-red-300text-decoration-color: #fca5a5;
decoration-red-400text-decoration-color: #f87171;
decoration-red-500text-decoration-color: #ef4444;
decoration-red-600text-decoration-color: #dc2626;
decoration-red-700text-decoration-color: #b91c1c;
decoration-red-800text-decoration-color: #991b1b;
decoration-red-900text-decoration-color: #7f1d1d;
decoration-red-950text-decoration-color: #450a0a;
decoration-orange-50text-decoration-color: #fff7ed;
decoration-orange-100text-decoration-color: #ffedd5;
decoration-orange-200text-decoration-color: #fed7aa;
decoration-orange-300text-decoration-color: #fdba74;
decoration-orange-400text-decoration-color: #fb923c;
decoration-orange-500text-decoration-color: #f97316;
decoration-orange-600text-decoration-color: #ea580c;
decoration-orange-700text-decoration-color: #c2410c;
decoration-orange-800text-decoration-color: #9a3412;
decoration-orange-900text-decoration-color: #7c2d12;
decoration-orange-950text-decoration-color: #431407;
decoration-amber-50text-decoration-color: #fffbeb;
decoration-amber-100text-decoration-color: #fef3c7;
decoration-amber-200text-decoration-color: #fde68a;
decoration-amber-300text-decoration-color: #fcd34d;
decoration-amber-400text-decoration-color: #fbbf24;
decoration-amber-500text-decoration-color: #f59e0b;
decoration-amber-600text-decoration-color: #d97706;
decoration-amber-700text-decoration-color: #b45309;
decoration-amber-800text-decoration-color: #92400e;
decoration-amber-900text-decoration-color: #78350f;
decoration-amber-950text-decoration-color: #451a03;
decoration-yellow-50text-decoration-color: #fefce8;
decoration-yellow-100text-decoration-color: #fef9c3;
decoration-yellow-200text-decoration-color: #fef08a;
decoration-yellow-300text-decoration-color: #fde047;
decoration-yellow-400text-decoration-color: #facc15;
decoration-yellow-500text-decoration-color: #eab308;
decoration-yellow-600text-decoration-color: #ca8a04;
decoration-yellow-700text-decoration-color: #a16207;
decoration-yellow-800text-decoration-color: #854d0e;
decoration-yellow-900text-decoration-color: #713f12;
decoration-yellow-950text-decoration-color: #422006;
decoration-lime-50text-decoration-color: #f7fee7;
decoration-lime-100text-decoration-color: #ecfccb;
decoration-lime-200text-decoration-color: #d9f99d;
decoration-lime-300text-decoration-color: #bef264;
decoration-lime-400text-decoration-color: #a3e635;
decoration-lime-500text-decoration-color: #84cc16;
decoration-lime-600text-decoration-color: #65a30d;
decoration-lime-700text-decoration-color: #4d7c0f;
decoration-lime-800text-decoration-color: #3f6212;
decoration-lime-900text-decoration-color: #365314;
decoration-lime-950text-decoration-color: #1a2e05;
decoration-green-50text-decoration-color: #f0fdf4;
decoration-green-100text-decoration-color: #dcfce7;
decoration-green-200text-decoration-color: #bbf7d0;
decoration-green-300text-decoration-color: #86efac;
decoration-green-400text-decoration-color: #4ade80;
decoration-green-500text-decoration-color: #22c55e;
decoration-green-600text-decoration-color: #16a34a;
decoration-green-700text-decoration-color: #15803d;
decoration-green-800text-decoration-color: #166534;
decoration-green-900text-decoration-color: #14532d;
decoration-green-950text-decoration-color: #052e16;
decoration-emerald-50text-decoration-color: #ecfdf5;
decoration-emerald-100text-decoration-color: #d1fae5;
decoration-emerald-200text-decoration-color: #a7f3d0;
decoration-emerald-300text-decoration-color: #6ee7b7;
decoration-emerald-400text-decoration-color: #34d399;
decoration-emerald-500text-decoration-color: #10b981;
decoration-emerald-600text-decoration-color: #059669;
decoration-emerald-700text-decoration-color: #047857;
decoration-emerald-800text-decoration-color: #065f46;
decoration-emerald-900text-decoration-color: #064e3b;
decoration-emerald-950text-decoration-color: #022c22;
decoration-teal-50text-decoration-color: #f0fdfa;
decoration-teal-100text-decoration-color: #ccfbf1;
decoration-teal-200text-decoration-color: #99f6e4;
decoration-teal-300text-decoration-color: #5eead4;
decoration-teal-400text-decoration-color: #2dd4bf;
decoration-teal-500text-decoration-color: #14b8a6;
decoration-teal-600text-decoration-color: #0d9488;
decoration-teal-700text-decoration-color: #0f766e;
decoration-teal-800text-decoration-color: #115e59;
decoration-teal-900text-decoration-color: #134e4a;
decoration-teal-950text-decoration-color: #042f2e;
decoration-cyan-50text-decoration-color: #ecfeff;
decoration-cyan-100text-decoration-color: #cffafe;
decoration-cyan-200text-decoration-color: #a5f3fc;
decoration-cyan-300text-decoration-color: #67e8f9;
decoration-cyan-400text-decoration-color: #22d3ee;
decoration-cyan-500text-decoration-color: #06b6d4;
decoration-cyan-600text-decoration-color: #0891b2;
decoration-cyan-700text-decoration-color: #0e7490;
decoration-cyan-800text-decoration-color: #155e75;
decoration-cyan-900text-decoration-color: #164e63;
decoration-cyan-950text-decoration-color: #083344;
decoration-sky-50text-decoration-color: #f0f9ff;
decoration-sky-100text-decoration-color: #e0f2fe;
decoration-sky-200text-decoration-color: #bae6fd;
decoration-sky-300text-decoration-color: #7dd3fc;
decoration-sky-400text-decoration-color: #38bdf8;
decoration-sky-500text-decoration-color: #0ea5e9;
decoration-sky-600text-decoration-color: #0284c7;
decoration-sky-700text-decoration-color: #0369a1;
decoration-sky-800text-decoration-color: #075985;
decoration-sky-900text-decoration-color: #0c4a6e;
decoration-sky-950text-decoration-color: #082f49;
decoration-blue-50text-decoration-color: #eff6ff;
decoration-blue-100text-decoration-color: #dbeafe;
decoration-blue-200text-decoration-color: #bfdbfe;
decoration-blue-300text-decoration-color: #93c5fd;
decoration-blue-400text-decoration-color: #60a5fa;
decoration-blue-500text-decoration-color: #3b82f6;
decoration-blue-600text-decoration-color: #2563eb;
decoration-blue-700text-decoration-color: #1d4ed8;
decoration-blue-800text-decoration-color: #1e40af;
decoration-blue-900text-decoration-color: #1e3a8a;
decoration-blue-950text-decoration-color: #172554;
decoration-indigo-50text-decoration-color: #eef2ff;
decoration-indigo-100text-decoration-color: #e0e7ff;
decoration-indigo-200text-decoration-color: #c7d2fe;
decoration-indigo-300text-decoration-color: #a5b4fc;
decoration-indigo-400text-decoration-color: #818cf8;
decoration-indigo-500text-decoration-color: #6366f1;
decoration-indigo-600text-decoration-color: #4f46e5;
decoration-indigo-700text-decoration-color: #4338ca;
decoration-indigo-800text-decoration-color: #3730a3;
decoration-indigo-900text-decoration-color: #312e81;
decoration-indigo-950text-decoration-color: #1e1b4b;
decoration-violet-50text-decoration-color: #f5f3ff;
decoration-violet-100text-decoration-color: #ede9fe;
decoration-violet-200text-decoration-color: #ddd6fe;
decoration-violet-300text-decoration-color: #c4b5fd;
decoration-violet-400text-decoration-color: #a78bfa;
decoration-violet-500text-decoration-color: #8b5cf6;
decoration-violet-600text-decoration-color: #7c3aed;
decoration-violet-700text-decoration-color: #6d28d9;
decoration-violet-800text-decoration-color: #5b21b6;
decoration-violet-900text-decoration-color: #4c1d95;
decoration-violet-950text-decoration-color: #2e1065;
decoration-purple-50text-decoration-color: #faf5ff;
decoration-purple-100text-decoration-color: #f3e8ff;
decoration-purple-200text-decoration-color: #e9d5ff;
decoration-purple-300text-decoration-color: #d8b4fe;
decoration-purple-400text-decoration-color: #c084fc;
decoration-purple-500text-decoration-color: #a855f7;
decoration-purple-600text-decoration-color: #9333ea;
decoration-purple-700text-decoration-color: #7e22ce;
decoration-purple-800text-decoration-color: #6b21a8;
decoration-purple-900text-decoration-color: #581c87;
decoration-purple-950text-decoration-color: #3b0764;
decoration-fuchsia-50text-decoration-color: #fdf4ff;
decoration-fuchsia-100text-decoration-color: #fae8ff;
decoration-fuchsia-200text-decoration-color: #f5d0fe;
decoration-fuchsia-300text-decoration-color: #f0abfc;
decoration-fuchsia-400text-decoration-color: #e879f9;
decoration-fuchsia-500text-decoration-color: #d946ef;
decoration-fuchsia-600text-decoration-color: #c026d3;
decoration-fuchsia-700text-decoration-color: #a21caf;
decoration-fuchsia-800text-decoration-color: #86198f;
decoration-fuchsia-900text-decoration-color: #701a75;
decoration-fuchsia-950text-decoration-color: #4a044e;
decoration-pink-50text-decoration-color: #fdf2f8;
decoration-pink-100text-decoration-color: #fce7f3;
decoration-pink-200text-decoration-color: #fbcfe8;
decoration-pink-300text-decoration-color: #f9a8d4;
decoration-pink-400text-decoration-color: #f472b6;
decoration-pink-500text-decoration-color: #ec4899;
decoration-pink-600text-decoration-color: #db2777;
decoration-pink-700text-decoration-color: #be185d;
decoration-pink-800text-decoration-color: #9d174d;
decoration-pink-900text-decoration-color: #831843;
decoration-pink-950text-decoration-color: #500724;
decoration-rose-50text-decoration-color: #fff1f2;
decoration-rose-100text-decoration-color: #ffe4e6;
decoration-rose-200text-decoration-color: #fecdd3;
decoration-rose-300text-decoration-color: #fda4af;
decoration-rose-400text-decoration-color: #fb7185;
decoration-rose-500text-decoration-color: #f43f5e;
decoration-rose-600text-decoration-color: #e11d48;
decoration-rose-700text-decoration-color: #be123c;
decoration-rose-800text-decoration-color: #9f1239;
decoration-rose-900text-decoration-color: #881337;
decoration-rose-950text-decoration-color: #4c0519;

Basic usage

Setting the text decoration color

Use the decoration-* utilities to change the color of an element’s text decoration.

I’m Derek, an astro-engineer based in Tattooine. I like to build X-Wings at My Company, Inc. Outside of work, I like to watch pod-racing and have light-saber fights.

<div>
  <p>
    I’m Derek, an astro-engineer based in Tattooine. I like to build X-Wings at
    <a class="underline decoration-sky-500">My Company, Inc</a>.
    Outside of work, I like to <a class="underline decoration-pink-500">watch
    pod-racing</a> and have <a class="underline decoration-indigo-500">light-saber</a> fights.
  </p>
</div>

Changing the opacity

Use the color opacity modifier to control the opacity of an element’s text decoration color.

I’m Derek, an astro-engineer based in Tattooine. I like to build X-Wings at My Company, Inc. Outside of work, I like to watch pod-racing and have light-saber fights.

<div>
  <p>
    I’m Derek, an astro-engineer based in Tattooine. I like to build X-Wings at
    <a class="underline decoration-sky-500/30">My Company, Inc</a>.
    Outside of work, I like to <a class="underline decoration-pink-500/30">watch
    pod-racing</a> and have <a class="underline decoration-indigo-500/30">light-saber</a> fights.
  </p>
</div>

You can use any value defined in your opacity scale, or use arbitrary values if you need to deviate from your design tokens.

<strong class="underline decoration-sky-500/[.33]"></strong>

Applying conditionally

Hover, focus, and other states

Tailwind lets you conditionally apply utility classes in different states using variant modifiers. For example, use hover:decoration-blue-400 to only apply the decoration-blue-400 utility on hover.

<p class="underline decoration-sky-600 hover:decoration-blue-400">
  <!-- ... -->
</p>

For a complete list of all available state modifiers, check out the Hover, Focus, & Other States documentation.

Breakpoints and media queries

You can also use variant modifiers to target media queries like responsive breakpoints, dark mode, prefers-reduced-motion, and more. For example, use md:decoration-blue-400 to apply the decoration-blue-400 utility at only medium screen sizes and above.

<p class="underline decoration-sky-600 md:decoration-blue-400">
  <!-- ... -->
</p>

To learn more, check out the documentation on Responsive Design, Dark Mode and other media query modifiers.


Using custom values

Customizing your theme

By default, Tailwind makes the entire default color palette available as text decoration colors. You can customize your color palette by editing theme.colors or theme.extend.colors in your tailwind.config.js file.

tailwind.config.js
module.exports = {
  theme: {
    extend: {
      colors: {
        'regal-blue': '#243c5a',
      },
    }
  }
}

Alternatively, you can customize just your text decoration colors by editing theme.textDecorationColor or theme.extend.textDecorationColor in your tailwind.config.js file.

Learn more about customizing the default theme in the theme customization documentation.

Arbitrary values

If you need to use a one-off text-decoration-color value that doesn’t make sense to include in your theme, use square brackets to generate a property on the fly using any arbitrary value.

<p class="decoration-[#50d71e]">
  <!-- ... -->
</p>

Learn more about arbitrary value support in the arbitrary values documentation.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。
列表为空,暂无数据
    我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
    原文