- 入门
- 核心概念
- 定制
- Base Styles
- 布局
- Flexbox & Grid
- Flex Basis
- Flex Direction
- Flex Wrap
- Flex
- Flex Grow
- Flex Shrink
- Order
- Grid Template Columns
- Grid Column Start / End
- Grid Template Rows
- Grid Row Start / End
- Grid Auto Flow
- Grid Auto Columns
- Grid Auto Rows
- Gap
- Justify Content
- Justify Items
- Justify Self
- Align Content
- Align Items
- Align Self
- Place Content
- Place Items
- Place Self
- 间隔
- 尺寸
- 排版
- Font Family
- Font Size
- Font Smoothing
- Font Style
- Font Weight
- Font Variant Numeric
- Letter Spacing
- Line Clamp
- Line Height
- List Style Image
- List Style Position
- List Style Type
- Text Align
- Text Color
- Text Decoration
- Text Decoration Color
- Text Decoration Style
- Text Decoration Thickness
- Text Underline Offset
- Text Transform
- Text Overflow
- Text Wrap
- Text Indent
- Vertical Align
- Whitespace
- Word Break
- Hyphens
- Content
- 背景
- 边框
- Effects
- Filters
- 表格 Tables
- Transitions & Animation
- Transforms
- Interactivity
- SVG
- Accessibility
- 其他
- Install Tailwind CSS using PostCSS
- Framework Guides
- Try Tailwind CSS using the Play CDN
- Install Tailwind CSS with Next.js
- Install Tailwind CSS with Laravel
- Install Tailwind CSS with Vite
- Install Tailwind CSS with Nuxt
- Install Tailwind CSS with Gatsby
- Install Tailwind CSS with SolidJS
- Install Tailwind CSS with SvelteKit
- Install Tailwind CSS with Angular
- Install Tailwind CSS with Ruby on Rails
- Install Tailwind CSS with Remix
- Install Tailwind CSS with Phoenix
- Install Tailwind CSS with Parcel
- Install Tailwind CSS with Symfony
- Install Tailwind CSS with Meteor
- Install Tailwind CSS with Create React App
- Install Tailwind CSS with Adonis
- Install Tailwind CSS With Ember.js
- Install Tailwind CSS with Astro
- Install Tailwind CSS with Qwik
- Install Tailwind CSS with Rspack
Text Color
Utilities for controlling the text color of an element.
Quick reference
Class | Preview |
---|---|
text-inherit | Aa |
text-current | Aa |
text-transparent | Aa |
text-black | Aa |
text-white | Aa |
text-slate-50 | Aa |
text-slate-100 | Aa |
text-slate-200 | Aa |
text-slate-300 | Aa |
text-slate-400 | Aa |
text-slate-500 | Aa |
text-slate-600 | Aa |
text-slate-700 | Aa |
text-slate-800 | Aa |
text-slate-900 | Aa |
text-slate-950 | Aa |
text-gray-50 | Aa |
text-gray-100 | Aa |
text-gray-200 | Aa |
text-gray-300 | Aa |
text-gray-400 | Aa |
text-gray-500 | Aa |
text-gray-600 | Aa |
text-gray-700 | Aa |
text-gray-800 | Aa |
text-gray-900 | Aa |
text-gray-950 | Aa |
text-zinc-50 | Aa |
text-zinc-100 | Aa |
text-zinc-200 | Aa |
text-zinc-300 | Aa |
text-zinc-400 | Aa |
text-zinc-500 | Aa |
text-zinc-600 | Aa |
text-zinc-700 | Aa |
text-zinc-800 | Aa |
text-zinc-900 | Aa |
text-zinc-950 | Aa |
text-neutral-50 | Aa |
text-neutral-100 | Aa |
text-neutral-200 | Aa |
text-neutral-300 | Aa |
text-neutral-400 | Aa |
text-neutral-500 | Aa |
text-neutral-600 | Aa |
text-neutral-700 | Aa |
text-neutral-800 | Aa |
text-neutral-900 | Aa |
text-neutral-950 | Aa |
text-stone-50 | Aa |
text-stone-100 | Aa |
text-stone-200 | Aa |
text-stone-300 | Aa |
text-stone-400 | Aa |
text-stone-500 | Aa |
text-stone-600 | Aa |
text-stone-700 | Aa |
text-stone-800 | Aa |
text-stone-900 | Aa |
text-stone-950 | Aa |
text-red-50 | Aa |
text-red-100 | Aa |
text-red-200 | Aa |
text-red-300 | Aa |
text-red-400 | Aa |
text-red-500 | Aa |
text-red-600 | Aa |
text-red-700 | Aa |
text-red-800 | Aa |
text-red-900 | Aa |
text-red-950 | Aa |
text-orange-50 | Aa |
text-orange-100 | Aa |
text-orange-200 | Aa |
text-orange-300 | Aa |
text-orange-400 | Aa |
text-orange-500 | Aa |
text-orange-600 | Aa |
text-orange-700 | Aa |
text-orange-800 | Aa |
text-orange-900 | Aa |
text-orange-950 | Aa |
text-amber-50 | Aa |
text-amber-100 | Aa |
text-amber-200 | Aa |
text-amber-300 | Aa |
text-amber-400 | Aa |
text-amber-500 | Aa |
text-amber-600 | Aa |
text-amber-700 | Aa |
text-amber-800 | Aa |
text-amber-900 | Aa |
text-amber-950 | Aa |
text-yellow-50 | Aa |
text-yellow-100 | Aa |
text-yellow-200 | Aa |
text-yellow-300 | Aa |
text-yellow-400 | Aa |
text-yellow-500 | Aa |
text-yellow-600 | Aa |
text-yellow-700 | Aa |
text-yellow-800 | Aa |
text-yellow-900 | Aa |
text-yellow-950 | Aa |
text-lime-50 | Aa |
text-lime-100 | Aa |
text-lime-200 | Aa |
text-lime-300 | Aa |
text-lime-400 | Aa |
text-lime-500 | Aa |
text-lime-600 | Aa |
text-lime-700 | Aa |
text-lime-800 | Aa |
text-lime-900 | Aa |
text-lime-950 | Aa |
text-green-50 | Aa |
text-green-100 | Aa |
text-green-200 | Aa |
text-green-300 | Aa |
text-green-400 | Aa |
text-green-500 | Aa |
text-green-600 | Aa |
text-green-700 | Aa |
text-green-800 | Aa |
text-green-900 | Aa |
text-green-950 | Aa |
text-emerald-50 | Aa |
text-emerald-100 | Aa |
text-emerald-200 | Aa |
text-emerald-300 | Aa |
text-emerald-400 | Aa |
text-emerald-500 | Aa |
text-emerald-600 | Aa |
text-emerald-700 | Aa |
text-emerald-800 | Aa |
text-emerald-900 | Aa |
text-emerald-950 | Aa |
text-teal-50 | Aa |
text-teal-100 | Aa |
text-teal-200 | Aa |
text-teal-300 | Aa |
text-teal-400 | Aa |
text-teal-500 | Aa |
text-teal-600 | Aa |
text-teal-700 | Aa |
text-teal-800 | Aa |
text-teal-900 | Aa |
text-teal-950 | Aa |
text-cyan-50 | Aa |
text-cyan-100 | Aa |
text-cyan-200 | Aa |
text-cyan-300 | Aa |
text-cyan-400 | Aa |
text-cyan-500 | Aa |
text-cyan-600 | Aa |
text-cyan-700 | Aa |
text-cyan-800 | Aa |
text-cyan-900 | Aa |
text-cyan-950 | Aa |
text-sky-50 | Aa |
text-sky-100 | Aa |
text-sky-200 | Aa |
text-sky-300 | Aa |
text-sky-400 | Aa |
text-sky-500 | Aa |
text-sky-600 | Aa |
text-sky-700 | Aa |
text-sky-800 | Aa |
text-sky-900 | Aa |
text-sky-950 | Aa |
text-blue-50 | Aa |
text-blue-100 | Aa |
text-blue-200 | Aa |
text-blue-300 | Aa |
text-blue-400 | Aa |
text-blue-500 | Aa |
text-blue-600 | Aa |
text-blue-700 | Aa |
text-blue-800 | Aa |
text-blue-900 | Aa |
text-blue-950 | Aa |
text-indigo-50 | Aa |
text-indigo-100 | Aa |
text-indigo-200 | Aa |
text-indigo-300 | Aa |
text-indigo-400 | Aa |
text-indigo-500 | Aa |
text-indigo-600 | Aa |
text-indigo-700 | Aa |
text-indigo-800 | Aa |
text-indigo-900 | Aa |
text-indigo-950 | Aa |
text-violet-50 | Aa |
text-violet-100 | Aa |
text-violet-200 | Aa |
text-violet-300 | Aa |
text-violet-400 | Aa |
text-violet-500 | Aa |
text-violet-600 | Aa |
text-violet-700 | Aa |
text-violet-800 | Aa |
text-violet-900 | Aa |
text-violet-950 | Aa |
text-purple-50 | Aa |
text-purple-100 | Aa |
text-purple-200 | Aa |
text-purple-300 | Aa |
text-purple-400 | Aa |
text-purple-500 | Aa |
text-purple-600 | Aa |
text-purple-700 | Aa |
text-purple-800 | Aa |
text-purple-900 | Aa |
text-purple-950 | Aa |
text-fuchsia-50 | Aa |
text-fuchsia-100 | Aa |
text-fuchsia-200 | Aa |
text-fuchsia-300 | Aa |
text-fuchsia-400 | Aa |
text-fuchsia-500 | Aa |
text-fuchsia-600 | Aa |
text-fuchsia-700 | Aa |
text-fuchsia-800 | Aa |
text-fuchsia-900 | Aa |
text-fuchsia-950 | Aa |
text-pink-50 | Aa |
text-pink-100 | Aa |
text-pink-200 | Aa |
text-pink-300 | Aa |
text-pink-400 | Aa |
text-pink-500 | Aa |
text-pink-600 | Aa |
text-pink-700 | Aa |
text-pink-800 | Aa |
text-pink-900 | Aa |
text-pink-950 | Aa |
text-rose-50 | Aa |
text-rose-100 | Aa |
text-rose-200 | Aa |
text-rose-300 | Aa |
text-rose-400 | Aa |
text-rose-500 | Aa |
text-rose-600 | Aa |
text-rose-700 | Aa |
text-rose-800 | Aa |
text-rose-900 | Aa |
text-rose-950 | Aa |
Basic usage
Setting the text color
Use the text-*
utilities to control the text color of an element.
The quick brown fox jumps over the lazy dog.
<p class="text-blue-600">The quick brown fox...</p>
Changing the opacity
Use the color opacity modifier to control the opacity of an element’s text color.
The quick brown fox jumps over the lazy dog.
The quick brown fox jumps over the lazy dog.
The quick brown fox jumps over the lazy dog.
The quick brown fox jumps over the lazy dog.
<p class="text-blue-600/100">The quick brown fox...</p>
<p class="text-blue-600/75">The quick brown fox...</p>
<p class="text-blue-600/50">The quick brown fox...</p>
<p class="text-blue-600/25">The quick brown fox...</p>
<p class="text-blue-600/0">The quick brown fox...</p>
You can use any value defined in your opacity scale, or use arbitrary values if you need to deviate from your design tokens.
<p class="text-blue-600/[.06]">The quick brown fox...</p>
Applying conditionally
Hover, focus, and other states
Tailwind lets you conditionally apply utility classes in different states using variant modifiers. For example, use hover:text-blue-600
to only apply the text-blue-600
utility on hover.
Try hovering over the text to see the expected behaviour
The quick brown fox jumps over the lazy dog.
<p class="text-slate-500 hover:text-blue-600">The quick brown fox...</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:text-green-600
to apply the text-green-600
utility at only medium screen sizes and above.
<p class="text-blue-600 md:text-green-600">
<!-- ... -->
</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 colors. You can customize your color palette by editing theme.colors
or theme.extend.colors
in your tailwind.config.js
file.
module.exports = {
theme: {
extend: {
colors: {
'regal-blue': '#243c5a',
},
}
}
}
Alternatively, you can customize just your text colors by editing theme.textColor
or theme.extend.textColor
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 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="text-[#50d71e]">
<!-- ... -->
</p>
Learn more about arbitrary value support in the arbitrary values documentation.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论