Text Color

    Utilities for controlling the text color of an element.

    Show all classes

    Control the text color of an element using the utilities.

    Changing the opacity

    Control the opacity of an element’s text color using the color opacity modifier.

    Text Color - 图2

    1. <p class="text-blue-600/100">The quick brown fox...</p>
    2. <p class="text-blue-600/75">The quick brown fox...</p>
    3. <p class="text-blue-600/50">The quick brown fox...</p>
    4. <p class="text-blue-600/25">The quick brown fox...</p>
    5. <p class="text-blue-600/0">The quick brown fox...</p>

    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

    Text Color - 图4

      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 to apply the text-green-600 utility at only medium screen sizes and above.


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

      tailwind.config.js

      1. module.exports = {
      2. theme: {
      3. extend: {
      4. colors: {
      5. },
      6. }
      7. }

      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.

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