Interactivity
Utilities for controlling the color of the text input cursor.
Use the caret-*
utilities to change the color of the text input cursor.
Focus the textarea to see the new caret color
<textarea class="caret-pink-500 ..."></textarea>
Tailwind lets you conditionally apply utility classes in different states using variant modifiers. For example, use focus:caret-indigo-500
to only apply the caret-indigo-500
utility on focus.
<textarea class="caret-blue-500 focus:caret-indigo-500"></textarea>
For a complete list of all available state modifiers, check out the Hover, Focus, & Other States documentation.
You can also use variant modifiers to target media queries like responsive breakpoints, dark mode, prefers-reduced-motion, and more. For example, use md:caret-indigo-500
to apply the caret-indigo-500
utility at only medium screen sizes and above.
<textarea class="caret-blue-500 md:caret-indigo-500"></textarea>
To learn more, check out the documentation on Responsive Design, Dark Mode and other media query modifiers.
By default, Tailwind makes the entire default color palette available as caret 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 caret colors by editing theme.caretColor
or theme.extend.caretColor
in your tailwind.config.js
file.
Learn more about customizing the default theme in the theme customization documentation.
If you need to use a one-off caret-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.
<textarea class="caret-[#50d71e]"></textarea>
Learn more about arbitrary value support in the arbitrary values documentation.