Tailwind Font Variant Numerics

Tailwind font variant numeric class enables you to manage the numeric glyphs of your text. It comes in handy when you require a specific format to display numbers, for example, in financial data or code snippets.

In this article, we will explore what font variant numeric styles are and how they can be used in Tailwind CSS.

Tailwind font variant numeric styles refer to a set of font properties that allow you to change the appearance of numerals in your text.

These properties include lining, old-style, proportional, tabular, and diagonal fractions.

Tailwind Font Variant Numerics

These styles are useful for creating beautiful and consistent typography on your website, especially when working with financial data, mathematical formulas, or any content that requires precise and consistent numerical display.



Tailwind Font Variant Numeric Classes

ClassesOverview
normal-numsIt applies the default numeric styling to the selected text with no special styling applied to them.
ordinalThis class renders ordinal numbers in superscript format. An ordinal number is a number that represents a position in a sequence (for example, 1st, 2nd, 3rd).
slashed-zeroUsing this class allows you to display the number zero with a slash. This can be useful in contexts where it’s needed to distinguish between the number zero and the letter “O”.
lining-numsThis class allows you to customize the style of your numbers. The “lining-nums” class ensures that all numbers in your text have a consistent size and shape, which can make your design look more polished.
oldstyle-numsThis class changes the style of your numbers to old-style numerals. Old-style numerals are a type of numeral that has a varying baseline.
proportional-numsThis class controls the display of numbers in a proportional font, where each number occupies a different amount of horizontal space.
tabular-numsThis property controls how numbers are displayed in a font, precisely when aligned in tables or columns. This class displays numbers in text with uniform widths.
diagonal-fractionsIt controls how fractions are displayed in text. This class will display fractions within an element’s text with a diagonal line separating the numerator and denominator when applied to that element.
stacked-fractionsThe purpose of this class is to enable the use of stacked fractions in your text. It is common to use stacked fractions in mathematical and scientific documents to display fractions in a more compact and readable format.

Syntax

<element class="Font-Variant-Numeric">...</element>

Below is an example implements lining-nums, oldstyle-nums and proportional-nums classes of Tailwind font variant numeric:

Example: 

<!DOCTYPE html> <html><head> <script src="https://cdn.tailwindcss.com"></script> </head> <body class="text-center mx-4 space-y-2"> <h1 class="text-gray-600 text-2xl font-semibold"> MrExamples </h1> <p class="font-semibold my-2 text-slate-800">Font Variant Numeric Class in Tailwind CSS</p> <div class="bg-gray-300 mx-24 h-full rounded p-2 font-medium"> <p class="lining-nums my-1">lining-nums: 123456789</p> <p class="oldstyle-nums my-1">oldstyle-nums: 123456789</p> <p class="proportional-nums my-1">proportional-nums: 565656</p> </div> </body> </html>
Here’s an example that uses the normal-nums and diagonal fractions classes to implement numeric glyphs in text:

Example: 

<!DOCTYPE html> <html><head> <script src="https://cdn.tailwindcss.com"></script> </head> <body class="text-center mx-4 space-y-2"> <h1 class="text-gray-600 text-2xl font-semibold"> MrExamples </h1> <p class="font-semibold my-2 text-slate-800">Font Variant Numeric Class in Tailwind CSS</p> <div class="bg-gray-300 mx-24 h-full rounded p-2 font-medium"> <p class="normal-nums my-1">normal-nums: 123456789</p> <p class="diagonal-fractions my-1">diagonal-fractions: 1/2 3/4 5/6</p> </div> </body> </html>
We value your feedback.
+1
0
+1
0
+1
0
+1
0
+1
0
+1
0
+1
0

Subscribe To Our Newsletter
Enter your email to receive a weekly round-up of our best posts. Learn more!
icon

Leave a Reply

Your email address will not be published. Required fields are marked *