Tailwind CSS tutorial #20: Font Variant Numeric

tailwind-css-tutorial-#20:-font-variant-numeric

In the article, we will go into detail on how to use font variant numeric.

Font Variant Numeric

Format

font variant numeric

Tailwind Class CSS Property
normal-nums font-variant-numeric: normal
ordinal font-variant-numeric: ordinal
slashed-zero font-variant-numeric: slashed-zero
lining-nums font-variant-numeric: lining-nums
oldstyle-nums font-variant-numeric: oldstyle-nums
proportional-nums font-variant-numeric: proportional-nums
tabular-nums font-variant-numeric: tabular-nums
diagonal-fractions font-variant-numeric: diagonal-fractions
stacked-fractions font-variant-numeric: stacked-fractions

Font variant numeric classes:

  • normal-nums: Using normal-nums will remove each effect of the font-variant-numeric class.
  • ordinal: This value directly indicates the open type values i.e. ordn. The term makes use of special glyphs for ordinal markers.
  • slashed-zero: This class slashed-zero used a zero with a slash, which proves to be very useful while distinguishing between 0 and O.
  • lining-nums: This class corresponds to the open type values i.e lnum. This keyword activates the numbers lying on the baseline.
  • oldstyle-nums: This class corresponds to the open type values i.e onum. This keyword activates the set of figures where some numbers have descendant.
  • proportional-nums: This class activates those norms where not every number is of the same size. Its open type value is pnum.
  • tabular-nums: This class open type value is tnum. It activates those sets of figures where a set of numbers is of the same size.
  • diagonal-fractions: It’s open type value is frac. This activates those sets of figures where numerator and denominator are made smaller and are separated by a slash.
  • stacked-fractions: It’s open type value is arac. This activates those set of figures where numerator and denominator are made smaller, stacked, and are separated by a horizontal line.

Code

 class="container mx-auto divide-y divide-gray-400 divide-dotted">
   class="flex items-center justify-between px-4 py-2">
    
class="font-sans font-light text-4xl align-middle mb-2" style="font-family: 'Source Sans Pro'">42nd
class="text-xs font-mono font-light text-gray-500 mt-2"> class="font-bold">font-variant-numeric: : normal
class="text-xs font-semibold font-mono whitespace-nowrap px-2 py-1 ml-5 rounded text-white bg-pink-500 rounded-2">normal-nums
class="flex items-center justify-between px-4 py-2">
class="ordinal font-sans font-light text-4xl align-middle mb-2" style="font-family: 'Source Sans Pro'">42nd
class="text-xs font-mono text-gray-500 mt-2"> class="font-bold">font-variant-numeric: ordinal
class="text-xs font-semibold font-mono whitespace-nowrap px-2 py-1 ml-5 rounded text-white bg-pink-500 rounded-2">ordinal
class="flex items-center justify-between px-4 py-2">
class="slashed-zero font-sans font-light text-4xl align-middle mb-2" style="font-family: 'Source Sans Pro'">20,000
class="text-xs font-mono font-light text-gray-500 mt-2"> class="font-bold">font-variant-numeric: slashed-zero
class="text-xs font-semibold font-mono whitespace-nowrap px-2 py-1 ml-5 rounded text-white bg-pink-500 rounded-2">slashed-zero
class="flex items-center justify-between px-4 py-2">
class="slashed-zero font-sans font-light text-4xl align-middle mb-2" style="font-family: 'Source Sans Pro'">802,701
class="text-xs font-mono font-light text-gray-500 mt-2"> class="font-bold">font-variant-numeric: lining-nums
class="text-xs font-semibold font-mono whitespace-nowrap px-2 py-1 ml-5 rounded text-white bg-green-500 rounded-2">lining-nums class="flex items-center justify-between px-4 py-2">
class="oldstyle-nums font-sans font-light text-4xl align-middle mb-2" style="font-family: 'Source Sans Pro'">299,792,458
class="text-xs font-mono font-light text-gray-500 mt-2"> class="font-bold">font-variant-numeric: oldstyle-nums class="text-xs font-semibold font-mono whitespace-nowrap px-2 py-1 ml-5 rounded text-white bg-green-500 rounded-2">oldstyle-nums class="flex items-center justify-between px-4 py-2">
class="proportional-nums font-sans font-light text-4xl align-middle" style="font-family: 'Source Sans Pro'">01-01-1885
class="proportional-nums font-sans font-light text-4xl align-middle mb-2" style="font-family: 'Source Sans Pro'">11-12-1955 class="text-xs font-mono font-light text-gray-500 mt-2"> class="font-bold">font-variant-numeric: proportional-nums class="text-xs font-semibold font-mono whitespace-nowrap px-2 py-1 ml-5 rounded text-white bg-blue-500 rounded-2">proportional-nums class="flex items-center justify-between px-4 py-2">
class="tabular-nums font-sans font-light text-4xl align-middle" style="font-family: 'Source Sans Pro'">01-01-1885
class="tabular-nums font-sans font-light text-4xl align-middle mb-2" style="font-family: 'Source Sans Pro'">11-12-1955 class="text-xs font-mono font-light text-gray-500 mt-2"> class="font-bold">font-variant-numeric: tabular-nums class="text-xs font-semibold font-mono whitespace-nowrap px-2 py-1 ml-5 rounded text-white bg-blue-500 rounded-2">tabular-nums class="flex items-center justify-between px-4 py-2">
class="diagonal-fractions font-sans font-light text-4xl align-middle mb-2">1/2
class="text-xs font-mono font-light text-gray-500 mt-2"> class="font-bold">font-variant-numeric: diagonal-fractions class="text-xs font-semibold font-mono whitespace-nowrap px-2 py-1 ml-5 rounded text-white bg-yellow-400 rounded-2">diagonal-fractions class="flex items-center justify-between px-4 py-2">
class="stacked-fractions font-mono font-light text-4xl align-middle mb-2" style="font-family: 'Ubuntu Mono'">1/2
class="text-xs font-mono font-light text-gray-500 mt-2"> class="font-bold">font-variant-numeric: stacked-fractions class="text-xs font-semibold font-mono whitespace-nowrap px-2 py-1 ml-5 rounded text-white bg-yellow-400 rounded-2">stacked-fractions

Full code:
The overall code will be attached to repo link.

Overall Output
Image descriptionImage description

Resources:
tailwind.css

Thank you for reading :), To learn more, check out my blogs on Flex Direction, Hackathons and Flex Wrap.
If you liked this article, consider following me on Dev.to for my latest publications. You can reach me on Twitter.

Keep learning! Keep coding!! 💛

Total
6
Shares
Leave a Reply

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

Previous Post
database-indexing-with-postgresql

Database Indexing with PostgreSQL

Next Post
we-fired-you,-but-keep-on-working-until-the-last-day!

We fired you, but keep on working until the last day!

Related Posts