Tailwind CSS 占位文本顏色

2022-08-08 10:02 更新

占位文本顏色

用于控制占位文本顏色的功能類。

Class
Properties
Preview 
placeholder-transparent::placeholder color: transparent;
Aa
placeholder-current::placeholder color: currentColor;
Aa
placeholder-black::placeholder --tw-placeholder-opacity: 1; color: rgba(0, 0, 0, var(--tw-placeholder-opacity));
Aa
placeholder-white::placeholder --tw-placeholder-opacity: 1; color: rgba(255, 255, 255, var(--tw-placeholder-opacity));
Aa
placeholder-gray-50::placeholder --tw-placeholder-opacity: 1; color: rgba(249, 250, 251, var(--tw-placeholder-opacity));
Aa
placeholder-gray-100::placeholder --tw-placeholder-opacity: 1; color: rgba(243, 244, 246, var(--tw-placeholder-opacity));
Aa
placeholder-gray-200::placeholder --tw-placeholder-opacity: 1; color: rgba(229, 231, 235, var(--tw-placeholder-opacity));
Aa
placeholder-gray-300::placeholder --tw-placeholder-opacity: 1; color: rgba(209, 213, 219, var(--tw-placeholder-opacity));
Aa
placeholder-gray-400::placeholder --tw-placeholder-opacity: 1; color: rgba(156, 163, 175, var(--tw-placeholder-opacity));
Aa
placeholder-gray-500::placeholder --tw-placeholder-opacity: 1; color: rgba(107, 114, 128, var(--tw-placeholder-opacity));
Aa
placeholder-gray-600::placeholder --tw-placeholder-opacity: 1; color: rgba(75, 85, 99, var(--tw-placeholder-opacity));
Aa
placeholder-gray-700::placeholder --tw-placeholder-opacity: 1; color: rgba(55, 65, 81, var(--tw-placeholder-opacity));
Aa
placeholder-gray-800::placeholder --tw-placeholder-opacity: 1; color: rgba(31, 41, 55, var(--tw-placeholder-opacity));
Aa
placeholder-gray-900::placeholder --tw-placeholder-opacity: 1; color: rgba(17, 24, 39, var(--tw-placeholder-opacity));
Aa
placeholder-red-50::placeholder --tw-placeholder-opacity: 1; color: rgba(254, 242, 242, var(--tw-placeholder-opacity));
Aa
placeholder-red-100::placeholder --tw-placeholder-opacity: 1; color: rgba(254, 226, 226, var(--tw-placeholder-opacity));
Aa
placeholder-red-200::placeholder --tw-placeholder-opacity: 1; color: rgba(254, 202, 202, var(--tw-placeholder-opacity));
Aa
placeholder-red-300::placeholder --tw-placeholder-opacity: 1; color: rgba(252, 165, 165, var(--tw-placeholder-opacity));
Aa
placeholder-red-400::placeholder --tw-placeholder-opacity: 1; color: rgba(248, 113, 113, var(--tw-placeholder-opacity));
Aa
placeholder-red-500::placeholder --tw-placeholder-opacity: 1; color: rgba(239, 68, 68, var(--tw-placeholder-opacity));
Aa
placeholder-red-600::placeholder --tw-placeholder-opacity: 1; color: rgba(220, 38, 38, var(--tw-placeholder-opacity));
Aa
placeholder-red-700::placeholder --tw-placeholder-opacity: 1; color: rgba(185, 28, 28, var(--tw-placeholder-opacity));
Aa
placeholder-red-800::placeholder --tw-placeholder-opacity: 1; color: rgba(153, 27, 27, var(--tw-placeholder-opacity));
Aa
placeholder-red-900::placeholder --tw-placeholder-opacity: 1; color: rgba(127, 29, 29, var(--tw-placeholder-opacity));
Aa
placeholder-yellow-50::placeholder --tw-placeholder-opacity: 1; color: rgba(255, 251, 235, var(--tw-placeholder-opacity));
Aa
placeholder-yellow-100::placeholder --tw-placeholder-opacity: 1; color: rgba(254, 243, 199, var(--tw-placeholder-opacity));
Aa
placeholder-yellow-200::placeholder --tw-placeholder-opacity: 1; color: rgba(253, 230, 138, var(--tw-placeholder-opacity));
Aa
placeholder-yellow-300::placeholder --tw-placeholder-opacity: 1; color: rgba(252, 211, 77, var(--tw-placeholder-opacity));
Aa
placeholder-yellow-400::placeholder --tw-placeholder-opacity: 1; color: rgba(251, 191, 36, var(--tw-placeholder-opacity));
Aa
placeholder-yellow-500::placeholder --tw-placeholder-opacity: 1; color: rgba(245, 158, 11, var(--tw-placeholder-opacity));
Aa
placeholder-yellow-600::placeholder --tw-placeholder-opacity: 1; color: rgba(217, 119, 6, var(--tw-placeholder-opacity));
Aa
placeholder-yellow-700::placeholder --tw-placeholder-opacity: 1; color: rgba(180, 83, 9, var(--tw-placeholder-opacity));
Aa
placeholder-yellow-800::placeholder --tw-placeholder-opacity: 1; color: rgba(146, 64, 14, var(--tw-placeholder-opacity));
Aa
placeholder-yellow-900::placeholder --tw-placeholder-opacity: 1; color: rgba(120, 53, 15, var(--tw-placeholder-opacity));
Aa
placeholder-green-50::placeholder --tw-placeholder-opacity: 1; color: rgba(236, 253, 245, var(--tw-placeholder-opacity));
Aa
placeholder-green-100::placeholder --tw-placeholder-opacity: 1; color: rgba(209, 250, 229, var(--tw-placeholder-opacity));
Aa
placeholder-green-200::placeholder --tw-placeholder-opacity: 1; color: rgba(167, 243, 208, var(--tw-placeholder-opacity));
Aa
placeholder-green-300::placeholder --tw-placeholder-opacity: 1; color: rgba(110, 231, 183, var(--tw-placeholder-opacity));
Aa
placeholder-green-400::placeholder --tw-placeholder-opacity: 1; color: rgba(52, 211, 153, var(--tw-placeholder-opacity));
Aa
placeholder-green-500::placeholder --tw-placeholder-opacity: 1; color: rgba(16, 185, 129, var(--tw-placeholder-opacity));
Aa
placeholder-green-600::placeholder --tw-placeholder-opacity: 1; color: rgba(5, 150, 105, var(--tw-placeholder-opacity));
Aa
placeholder-green-700::placeholder --tw-placeholder-opacity: 1; color: rgba(4, 120, 87, var(--tw-placeholder-opacity));
Aa
placeholder-green-800::placeholder --tw-placeholder-opacity: 1; color: rgba(6, 95, 70, var(--tw-placeholder-opacity));
Aa
placeholder-green-900::placeholder --tw-placeholder-opacity: 1; color: rgba(6, 78, 59, var(--tw-placeholder-opacity));
Aa
placeholder-blue-50::placeholder --tw-placeholder-opacity: 1; color: rgba(239, 246, 255, var(--tw-placeholder-opacity));
Aa
placeholder-blue-100::placeholder --tw-placeholder-opacity: 1; color: rgba(219, 234, 254, var(--tw-placeholder-opacity));
Aa
placeholder-blue-200::placeholder --tw-placeholder-opacity: 1; color: rgba(191, 219, 254, var(--tw-placeholder-opacity));
Aa
placeholder-blue-300::placeholder --tw-placeholder-opacity: 1; color: rgba(147, 197, 253, var(--tw-placeholder-opacity));
Aa
placeholder-blue-400::placeholder --tw-placeholder-opacity: 1; color: rgba(96, 165, 250, var(--tw-placeholder-opacity));
Aa
placeholder-blue-500::placeholder --tw-placeholder-opacity: 1; color: rgba(59, 130, 246, var(--tw-placeholder-opacity));
Aa
placeholder-blue-600::placeholder --tw-placeholder-opacity: 1; color: rgba(37, 99, 235, var(--tw-placeholder-opacity));
Aa
placeholder-blue-700::placeholder --tw-placeholder-opacity: 1; color: rgba(29, 78, 216, var(--tw-placeholder-opacity));
Aa
placeholder-blue-800::placeholder --tw-placeholder-opacity: 1; color: rgba(30, 64, 175, var(--tw-placeholder-opacity));
Aa
placeholder-blue-900::placeholder --tw-placeholder-opacity: 1; color: rgba(30, 58, 138, var(--tw-placeholder-opacity));
Aa
placeholder-indigo-50::placeholder --tw-placeholder-opacity: 1; color: rgba(238, 242, 255, var(--tw-placeholder-opacity));
Aa
placeholder-indigo-100::placeholder --tw-placeholder-opacity: 1; color: rgba(224, 231, 255, var(--tw-placeholder-opacity));
Aa
placeholder-indigo-200::placeholder --tw-placeholder-opacity: 1; color: rgba(199, 210, 254, var(--tw-placeholder-opacity));
Aa
placeholder-indigo-300::placeholder --tw-placeholder-opacity: 1; color: rgba(165, 180, 252, var(--tw-placeholder-opacity));
Aa
placeholder-indigo-400::placeholder --tw-placeholder-opacity: 1; color: rgba(129, 140, 248, var(--tw-placeholder-opacity));
Aa
placeholder-indigo-500::placeholder --tw-placeholder-opacity: 1; color: rgba(99, 102, 241, var(--tw-placeholder-opacity));
Aa
placeholder-indigo-600::placeholder --tw-placeholder-opacity: 1; color: rgba(79, 70, 229, var(--tw-placeholder-opacity));
Aa
placeholder-indigo-700::placeholder --tw-placeholder-opacity: 1; color: rgba(67, 56, 202, var(--tw-placeholder-opacity));
Aa
placeholder-indigo-800::placeholder --tw-placeholder-opacity: 1; color: rgba(55, 48, 163, var(--tw-placeholder-opacity));
Aa
placeholder-indigo-900::placeholder --tw-placeholder-opacity: 1; color: rgba(49, 46, 129, var(--tw-placeholder-opacity));
Aa
placeholder-purple-50::placeholder --tw-placeholder-opacity: 1; color: rgba(245, 243, 255, var(--tw-placeholder-opacity));
Aa
placeholder-purple-100::placeholder --tw-placeholder-opacity: 1; color: rgba(237, 233, 254, var(--tw-placeholder-opacity));
Aa
placeholder-purple-200::placeholder --tw-placeholder-opacity: 1; color: rgba(221, 214, 254, var(--tw-placeholder-opacity));
Aa
placeholder-purple-300::placeholder --tw-placeholder-opacity: 1; color: rgba(196, 181, 253, var(--tw-placeholder-opacity));
Aa
placeholder-purple-400::placeholder --tw-placeholder-opacity: 1; color: rgba(167, 139, 250, var(--tw-placeholder-opacity));
Aa
placeholder-purple-500::placeholder --tw-placeholder-opacity: 1; color: rgba(139, 92, 246, var(--tw-placeholder-opacity));
Aa
placeholder-purple-600::placeholder --tw-placeholder-opacity: 1; color: rgba(124, 58, 237, var(--tw-placeholder-opacity));
Aa
placeholder-purple-700::placeholder --tw-placeholder-opacity: 1; color: rgba(109, 40, 217, var(--tw-placeholder-opacity));
Aa
placeholder-purple-800::placeholder --tw-placeholder-opacity: 1; color: rgba(91, 33, 182, var(--tw-placeholder-opacity));
Aa
placeholder-purple-900::placeholder --tw-placeholder-opacity: 1; color: rgba(76, 29, 149, var(--tw-placeholder-opacity));
Aa
placeholder-pink-50::placeholder --tw-placeholder-opacity: 1; color: rgba(253, 242, 248, var(--tw-placeholder-opacity));
Aa
placeholder-pink-100::placeholder --tw-placeholder-opacity: 1; color: rgba(252, 231, 243, var(--tw-placeholder-opacity));
Aa
placeholder-pink-200::placeholder --tw-placeholder-opacity: 1; color: rgba(251, 207, 232, var(--tw-placeholder-opacity));
Aa
placeholder-pink-300::placeholder --tw-placeholder-opacity: 1; color: rgba(249, 168, 212, var(--tw-placeholder-opacity));
Aa
placeholder-pink-400::placeholder --tw-placeholder-opacity: 1; color: rgba(244, 114, 182, var(--tw-placeholder-opacity));
Aa
placeholder-pink-500::placeholder --tw-placeholder-opacity: 1; color: rgba(236, 72, 153, var(--tw-placeholder-opacity));
Aa
placeholder-pink-600::placeholder --tw-placeholder-opacity: 1; color: rgba(219, 39, 119, var(--tw-placeholder-opacity));
Aa
placeholder-pink-700::placeholder --tw-placeholder-opacity: 1; color: rgba(190, 24, 93, var(--tw-placeholder-opacity));
Aa
placeholder-pink-800::placeholder --tw-placeholder-opacity: 1; color: rgba(157, 23, 77, var(--tw-placeholder-opacity));
Aa
placeholder-pink-900::placeholder --tw-placeholder-opacity: 1; color: rgba(131, 24, 67, var(--tw-placeholder-opacity));
Aa

使用方法

使用 ?placeholder-{color}? 功能類控制元素占位文本的顏色。


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

改變不透明度

使用 ?placeholder-opacity-{amount}? 功能類控制元素的占位文本顏色的不透明度。


<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">

響應(yīng)式

要在特定的斷點(diǎn)處控制輸入框占位文本的顏色,請(qǐng)?jiān)谌魏维F(xiàn)有的占位文本顏色功能類前添加 ?{screen}:? 前綴。例如,使用 ?md:placeholder-green-500? 來(lái)僅在中等大小及以上的屏幕應(yīng)用 ?placeholder-green-500? 功能類。

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

關(guān)于 Tailwind 的響應(yīng)式設(shè)計(jì)功能的更多信息,請(qǐng)查看 響應(yīng)式設(shè)計(jì) 文檔。

焦點(diǎn)

要控制獲得焦點(diǎn)時(shí)元素的占位文本顏色,請(qǐng)?jiān)谌魏维F(xiàn)有的占位文本顏色功能類前添加 ?focus:? 前綴。例如,使用 ?focus:placeholder-blue-600? 在獲得焦點(diǎn)時(shí)應(yīng)用 ?placeholder-blue-600? 功能類。


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

通過(guò)在 ?focus:? 前綴前添加響應(yīng)式 ?{screen}:? 前綴,focus 功能類也可以與 responsive 功能類相結(jié)合。

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

自定義

占位符文本顏色

默認(rèn)情況下,Tailwind 使整個(gè)默認(rèn)調(diào)色板可用作占位符顏色。

您可以通過(guò)編輯 ?tailwind.config.js? 文件中的 ?theme.colors? 來(lái) 自定義您的調(diào)色板,或者在 ?theme.textColor? 部分只自定義您的占位文本顏色。

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

變體

默認(rèn)情況下, 針對(duì) placeholder color 功能類,只生成 responsive, dark mode (if enabled) and focus 變體。

您可以通過(guò)修改您的 ?tailwind.config.js? 文件中的 ?variants ?部分中的 ?placeholderColor ?屬性來(lái)控制為 placeholder color 功能生成哪些變體。

例如,這個(gè)配置也將生成 hover and active 變體:

  // tailwind.config.js
  module.exports = {
    variants: {
      extend: {
        // ...
       placeholderColor: ['hover', 'active'],
      }
    }
  }

禁用

如果您不打算在您的項(xiàng)目中使用 placeholder color 功能,您可以通過(guò)在配置文件的 ?corePlugins ?部分將 ?placeholderColor ?屬性設(shè)置為 ?false ?來(lái)完全禁用它們:

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


以上內(nèi)容是否對(duì)您有幫助:
在線筆記
App下載
App下載

掃描二維碼

下載編程獅App

公眾號(hào)
微信公眾號(hào)

編程獅公眾號(hào)