tailwind-css
  1. tailwind-css-font-variant-numeric

Tailwind CSS Font Variant Numeric

With the Tailwind CSS Font Variant Numeric utility classes, you can easily set the font-variant-numeric CSS property to control the display of numeric glyphs. This can be useful in scenarios such as displaying tabular data or mathematical symbols.

Syntax

The syntax for using the font-variant-numeric utility classes in Tailwind CSS is as follows:

<div class="font-variant-numeric-ordinal font-variant-numeric-proportional ..."></div>

Example

Here's an example of using the font-variant-numeric utility classes in HTML to control the display of numeric glyphs:

<h1 class="font-variant-numeric-ordinal">1st</h1>
<h1 class="font-variant-numeric-proportional">100</h1>

Output

The above HTML code will produce the following output:

1st

100

Explanation

The font-variant-numeric CSS property controls the display of numeric glyphs, such as those used in fractions, ordinal numbers, and tabular data. The most common values for this property include "normal", "ordinal", and "proportional".

The Tailwind CSS Font Variant Numeric utility classes provide a convenient way to set the font-variant-numeric property in your HTML code. The font-variant-numeric-ordinal class sets the property to "ordinal", which will display numeric glyphs as ordinal numbers (e.g. “1st”, “2nd”, "3rd”, etc.), while the font-variant-numeric-proportional class sets the property to "proportional", which will display numeric glyphs as proportional numerals (e.g. “100”).

Use

The Tailwind CSS Font Variant Numeric utility classes are especially useful in scenarios where you need to display numeric data in a clear and easy-to-read manner, such as in tables or financial reports.

To use these classes in your HTML code, simply add the appropriate class to the element you want to style. You can also chain multiple classes together to apply multiple styles to the same element.

Important Points

  • The font-variant-numeric property is supported in most modern browsers, including Chrome, Firefox, Safari, and Edge.
  • The property only affects the display of numeric glyphs, and does not affect the display of other characters.
  • In addition to the font-variant-numeric-ordinal and font-variant-numeric-proportional classes, Tailwind CSS also provides classes for other values of the font-variant-numeric property, such as font-variant-numeric-lining, font-variant-numeric-tabular, and font-variant-numeric-diagonal-fractions.

Summary

The Tailwind CSS Font Variant Numeric utility classes provide a simple and easy-to-use way to control the display of numeric glyphs in your HTML code. Whether you need to display numeric data in tables or financial reports, or simply want to style numeric content for visual appeal, these classes make it easy to achieve the desired effect.

Published on: