Ring Color

Utilities for setting the color of outline rings.

Default class reference

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

Usage

Use the ring-{color} utilities to set the color of an outline ring.

Ring Color - 图1

  1. <button class="... ring-4 ring-indigo-300">
  2. Button
  3. </button>

Changing opacity

You can control the opacity of rings using the ring-opacity-{amount} utilities:

Ring Color - 图2

  1. <button class="... ring-4 ring-yellow-500 ring-opacity-50">
  2. Button
  3. </button>

For more information, see the ringOpacity documentation.


Responsive

To control the ring color at a specific breakpoint, add a {screen}: prefix to any existing ring color utility. For example, use md:ring-blue-500 to apply the ring-blue-500 utility at only medium screen sizes and above.

  1. <button class="ring-2 ring-blue-300 md:ring-blue-500">
  2. <!-- ... -->
  3. </button>

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


Customizing

You can customize which ring color utilities are generated by customizing your color palette using the colors key in the theme section of your tailwind.config.js file:

  1. // tailwind.config.js
  2. const colors = require('tailwindcss/colors')
  3. module.exports = {
  4. theme: {
  5. colors: {
  6. gray: colors.blueGray,
  7. indigo: colors.indigo,
  8. red: colors.rose,
  9. yellow: colors.yellow,
  10. }
  11. }
  12. }

If you’d like to customize only the ring color utilities without affecting your global color palette, use the ringColor key instead:

  1. // tailwind.config.js
  2. const colors = require('tailwindcss/colors')
  3. module.exports = {
  4. theme: {
  5. ringColor: {
  6. white: colors.white,
  7. pink: colors.fuchsia,
  8. }
  9. }
  10. }

Learn more about customizing the default theme in the theme customization documentation.

Variants

By default, only responsive, dark mode (if enabled), focus-within and focus variants are generated for ring color utilities.

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

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

  1. // tailwind.config.js
  2. module.exports = {
  3. variants: {
  4. extend: {
  5. // ...
  6. + ringColor: ['hover', 'active'],
  7. }
  8. }
  9. }

Disabling

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

  1. // tailwind.config.js
  2. module.exports = {
  3. corePlugins: {
  4. // ...
  5. + ringColor: false,
  6. }
  7. }

←Ring Width Ring Opacity→

Edit this page on GitHub