Placeholder Colorv1.1.0+

Utilities for controlling the color of placeholder text.

Class reference

Class
Preview 
.placeholder-transparent::placeholderAa
.placeholder-current::placeholderAa
.placeholder-black::placeholderAa
.placeholder-white::placeholderAa
.placeholder-gray-100::placeholderAa
.placeholder-gray-200::placeholderAa
.placeholder-gray-300::placeholderAa
.placeholder-gray-400::placeholderAa
.placeholder-gray-500::placeholderAa
.placeholder-gray-600::placeholderAa
.placeholder-gray-700::placeholderAa
.placeholder-gray-800::placeholderAa
.placeholder-gray-900::placeholderAa
.placeholder-red-100::placeholderAa
.placeholder-red-200::placeholderAa
.placeholder-red-300::placeholderAa
.placeholder-red-400::placeholderAa
.placeholder-red-500::placeholderAa
.placeholder-red-600::placeholderAa
.placeholder-red-700::placeholderAa
.placeholder-red-800::placeholderAa
.placeholder-red-900::placeholderAa
.placeholder-orange-100::placeholderAa
.placeholder-orange-200::placeholderAa
.placeholder-orange-300::placeholderAa
.placeholder-orange-400::placeholderAa
.placeholder-orange-500::placeholderAa
.placeholder-orange-600::placeholderAa
.placeholder-orange-700::placeholderAa
.placeholder-orange-800::placeholderAa
.placeholder-orange-900::placeholderAa
.placeholder-yellow-100::placeholderAa
.placeholder-yellow-200::placeholderAa
.placeholder-yellow-300::placeholderAa
.placeholder-yellow-400::placeholderAa
.placeholder-yellow-500::placeholderAa
.placeholder-yellow-600::placeholderAa
.placeholder-yellow-700::placeholderAa
.placeholder-yellow-800::placeholderAa
.placeholder-yellow-900::placeholderAa
.placeholder-green-100::placeholderAa
.placeholder-green-200::placeholderAa
.placeholder-green-300::placeholderAa
.placeholder-green-400::placeholderAa
.placeholder-green-500::placeholderAa
.placeholder-green-600::placeholderAa
.placeholder-green-700::placeholderAa
.placeholder-green-800::placeholderAa
.placeholder-green-900::placeholderAa
.placeholder-teal-100::placeholderAa
.placeholder-teal-200::placeholderAa
.placeholder-teal-300::placeholderAa
.placeholder-teal-400::placeholderAa
.placeholder-teal-500::placeholderAa
.placeholder-teal-600::placeholderAa
.placeholder-teal-700::placeholderAa
.placeholder-teal-800::placeholderAa
.placeholder-teal-900::placeholderAa
.placeholder-blue-100::placeholderAa
.placeholder-blue-200::placeholderAa
.placeholder-blue-300::placeholderAa
.placeholder-blue-400::placeholderAa
.placeholder-blue-500::placeholderAa
.placeholder-blue-600::placeholderAa
.placeholder-blue-700::placeholderAa
.placeholder-blue-800::placeholderAa
.placeholder-blue-900::placeholderAa
.placeholder-indigo-100::placeholderAa
.placeholder-indigo-200::placeholderAa
.placeholder-indigo-300::placeholderAa
.placeholder-indigo-400::placeholderAa
.placeholder-indigo-500::placeholderAa
.placeholder-indigo-600::placeholderAa
.placeholder-indigo-700::placeholderAa
.placeholder-indigo-800::placeholderAa
.placeholder-indigo-900::placeholderAa
.placeholder-purple-100::placeholderAa
.placeholder-purple-200::placeholderAa
.placeholder-purple-300::placeholderAa
.placeholder-purple-400::placeholderAa
.placeholder-purple-500::placeholderAa
.placeholder-purple-600::placeholderAa
.placeholder-purple-700::placeholderAa
.placeholder-purple-800::placeholderAa
.placeholder-purple-900::placeholderAa
.placeholder-pink-100::placeholderAa
.placeholder-pink-200::placeholderAa
.placeholder-pink-300::placeholderAa
.placeholder-pink-400::placeholderAa
.placeholder-pink-500::placeholderAa
.placeholder-pink-600::placeholderAa
.placeholder-pink-700::placeholderAa
.placeholder-pink-800::placeholderAa
.placeholder-pink-900::placeholderAa

Usage

Control the placeholder color of an element using the .placeholder-{color} utilities.

<input class="placeholder-gray-500 border" placeholder="jane@example.com">
<input class="placeholder-red-300 border border-red-400" placeholder="jane@example.com">

Changing opacityv1.4.0+

Control the opacity of an element's placeholder color using the .placeholder-opacity-{amount} utilities.

<input class="placeholder-gray-500 placeholder-opacity-100 ..." placeholder="jane@example.com">
<input class="placeholder-gray-500 placeholder-opacity-75 ..." placeholder="jane@example.com">
<input class="placeholder-gray-500 placeholder-opacity-50 ..." placeholder="jane@example.com">
<input class="placeholder-gray-500 placeholder-opacity-25 ..." placeholder="jane@example.com">
<input class="placeholder-gray-500 placeholder-opacity-0 ..." placeholder="jane@example.com">

Learn more in the placeholder opacity documentation.

Responsive

To control the text color of an element at a specific breakpoint, add a {screen}: prefix to any existing text color utility. For example, use md:text-green-600 to apply the text-green-600 utility at only medium screen sizes and above.

For more information about Tailwind's responsive design features, check out the Responsive Design documentation.

<input class="placeholder-gray-500 sm:placeholder-red-400 md:placeholder-blue-400 lg:placeholder-green-400 xl:placeholder-orange-400" placeholder="jane@example.com">

Focus

To control the placeholder color of an element on focus, add the focus: prefix to any existing placeholder color utility. For example, use focus:placeholder-blue-600 to apply the placeholder-blue-600 utility on focus.

<input class="placeholder-gray-600 focus:placeholder-gray-500 ..." placeholder="jane@example.com">

Focus utilities can also be combined with responsive utilities by adding the responsive {screen}: prefix before the focus: prefix.

<input class="... md:placeholder-gray-900 md:focus:placeholder-red-600 ...">

Customizing

Placeholder Colors

By default Tailwind makes the entire default color palette available as placeholder colors.

You can customize your color palette by editing theme.colors in your tailwind.config.js file, or customize just your placeholder colors in the theme.textColor section.

  // tailwind.config.js
  module.exports = {
    theme: {
-     placeholderColor: theme => theme('colors'),
+     placeholderColor: {
+       'primary': '#3490dc',
+       'secondary': '#ffed4a',
+       'danger': '#e3342f',
+     }
    }
  }

Responsive and pseudo-class variants

By default, only responsive and focus variants are generated for placeholder color utilities.

You can control which variants are generated for the placeholder color utilities by modifying the placeholderColor property in the variants section of your tailwind.config.js file.

For example, this config will also generate hover and active variants:

  // tailwind.config.js
  module.exports = {
    variants: {
      // ...
-     placeholderColor: ['responsive', 'focus'],
+     placeholderColor: ['responsive', 'focus', 'hover', 'active'],
    }
  }

Disabling

If you don't plan to use the placeholder color utilities in your project, you can disable them entirely by setting the placeholderColor property to false in the corePlugins section of your config file:

  // tailwind.config.js
  module.exports = {
    corePlugins: {
      // ...
+     placeholderColor: false,
    }
  }

Tailwind UI is now in early access!