- Published on
How to Build A Font Preview With Tailwind CSS?
- What is Tailwind CSS?
- The description of Font Preview ui component
- Why use Tailwind CSS to create a Font Preview ui component?
- The preview of Font Preview ui component
- The source code of Font Preview ui component
- How to create a Font Preview with Tailwind CSS?
- Install tailwind css of verion 2.0.2
- All the unility class needed to create a Font Preview component
- 68 steps to create a Font Preview component with Tailwind CSS
- Conclusion
What is Tailwind CSS?
Tailwind CSS is a utility-first CSS framework that focuses on creating personalized user interfaces quickly. It can gives you all the building blocks you are able to create personalized designs without having to fight to override irritating opinionated styles. Also, Tailwind CSS is a highly configurable, low-level CSS framework.
The description of Font Preview ui component
Alpinejs font previewer
Why use Tailwind CSS to create a Font Preview ui component?
- It can make the building process of Font Preview ui component faster and more easily.
- Enables building complex responsive layouts and components freely.
- Minimum lines of CSS code in Font Preview component file.
The preview of Font Preview ui component
Free download of the Font Preview's source code
The source code of Font Preview ui component
<script src="https://cdn.jsdelivr.net/gh/alpinejs/[email protected]/dist/alpine.js" defer></script>
<style>@import url(https://cdnjs.cloudflare.com/ajax/libs/MaterialDesign-Webfont/5.3.45/css/materialdesignicons.min.css);</style>
<style>
/*
module.exports = {
plugins: [require('@tailwindcss/forms'),]
};
*/
.form-radio {
-webkit-appearance: none;
-moz-appearance: none;
appearance: none;
-webkit-print-color-adjust: exact;
color-adjust: exact;
display: inline-block;
vertical-align: middle;
background-origin: border-box;
-webkit-user-select: none;
-moz-user-select: none;
-ms-user-select: none;
user-select: none;
flex-shrink: 0;
border-radius: 100%;
border-width: 2px;
}
.form-radio:checked {
background-image: url("data:image/svg+xml,%3csvg viewBox='0 0 16 16' fill='white' xmlns='http://www.w3.org/2000/svg'%3e%3ccircle cx='8' cy='8' r='3'/%3e%3c/svg%3e");
border-color: transparent;
background-color: currentColor;
background-size: 100% 100%;
background-position: center;
background-repeat: no-repeat;
}
@media not print {
.form-radio::-ms-check {
border-width: 1px;
color: transparent;
background: inherit;
border-color: inherit;
border-radius: inherit;
}
}
.form-radio:focus {
outline: none;
}
.form-select {
background-image: url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='%23a0aec0'%3e%3cpath d='M15.3 9.3a1 1 0 0 1 1.4 1.4l-4 4a1 1 0 0 1-1.4 0l-4-4a1 1 0 0 1 1.4-1.4l3.3 3.29 3.3-3.3z'/%3e%3c/svg%3e");
-webkit-appearance: none;
-moz-appearance: none;
appearance: none;
-webkit-print-color-adjust: exact;
color-adjust: exact;
background-repeat: no-repeat;
padding-top: 0.5rem;
padding-right: 2.5rem;
padding-bottom: 0.5rem;
font-size: 1rem;
line-height: 1.5;
background-position: right 0.5rem center;
background-size: 1.5em 1.5em;
}
.form-select::-ms-expand {
color: #a0aec0;
border: none;
}
@media not print {
.form-select::-ms-expand {
display: none;
}
}
@media print and (-ms-high-contrast: active), print and (-ms-high-contrast: none) {
.form-select {
padding-right: 0.75rem;
}
}
/* CHECKBOX TOGGLE SWITCH */
/* @apply rules for documentation, these do not work as inline style */
.toggle-checkbox:checked {
@apply: right-0 border-transparent;
right: 0;
border-color: transparent;
}
.toggle-checkbox:checked + .toggle-label {
/*@apply: bg-green-400;*/
/*background-color: #68D391;*/
}
</style>
<div class="min-w-screen min-h-screen bg-gray-800 flex items-center justify-center px-5 py-5">
<div class="w-full mx-auto bg-white shadow text-gray-700 max-w-4xl" x-data="app()">
<div class="md:flex">
<div class="md:w-1/2 p-10 flex items-center justify-center text-center transition-colors" :class="darkMode?`bg-${color}-500 text-white`:`text-${color}-500 bg-white`" :style="`font-family: '${selectedFont}', sans-serif;`">
<div>
<h1 class="leading-none" :class="fontStyle" :style="`font-size: ${fontSize}rem`">Ab</h1>
<p class="text-lg"><span x-text="selectedFont"></span></p>
<div class="mt-8">
<label for="toggle" class="relative inline-block w-10 mr-2 align-middle select-none transition duration-200 ease-in">
<input id="toggle" type="checkbox" class="toggle-checkbox absolute block w-4 h-4 mt-1 mx-1 rounded-full bg-white border-none appearance-none cursor-pointer outline-none focus:outline-none transition-all" x-model="darkMode" value="1"/>
<span class="toggle-label block overflow-hidden h-6 rounded-full bg-gray-900 bg-opacity-20 cursor-pointer focus:outline-none transition-all"></span>
</label>
</div>
</div>
</div>
<div class="md:w-1/2 px-10 py-14">
<div class="mb-3">
<label class="block font-medium text-xs ml-1 text-gray-400">Font</label>
<div>
<select class="w-full form-select pl-1 mb-1 border-b-2 border-gray-200 focus:outline-none focus:border-indigo-500 transition-colors cursor-pointer" x-model="selectedFont">
<template x-for="font in googleFonts">
<option :value="font" x-text="font" :selected="selectedFont==font"></option>
</template>
</select>
</div>
</div>
<div class="mb-3">
<label class="block font-medium text-xs ml-1 text-gray-400">Style</label>
<div>
<select class="w-full form-select pl-1 mb-1 border-b-2 border-gray-200 focus:outline-none focus:border-indigo-500 transition-colors cursor-pointer" x-model="fontStyle">
<option value="normal" selected>Normal</option>
<option value="italic">Italic</option>
</select>
</div>
</div>
<div class="mb-4">
<label class="block font-medium text-xs mb-2 ml-1 text-gray-400">Color</label>
<div>
<input type="radio" class="form-radio h-10 w-10 text-blue-500 bg-blue-500 border-white" x-model="color" value="blue" checked>
<input type="radio" class="form-radio h-10 w-10 text-indigo-500 bg-indigo-500 border-white" x-model="color" value="indigo">
<input type="radio" class="form-radio h-10 w-10 text-red-500 bg-red-500 border-white" x-model="color" value="red">
<input type="radio" class="form-radio h-10 w-10 text-yellow-500 bg-yellow-500 border-white" x-model="color" value="yellow">
<input type="radio" class="form-radio h-10 w-10 text-green-500 bg-green-500 border-white" x-model="color" value="green">
<input type="radio" class="form-radio h-10 w-10 text-gray-500 bg-gray-500 border-white" x-model="color" value="gray">
</div>
</div>
<div class="">
<label class="block font-medium text-xs mb-2 ml-1 text-gray-400">Size</label>
<div>
<input class="w-full" type="range" x-model="fontSize" min="4" max="12" step="1">
</div>
</div>
</div>
</div>
<link rel="preconnect" href="https://fonts.gstatic.com">
<link :href="`https://fonts.googleapis.com/css2?family=${selectedFont}&display=swap`" rel="stylesheet">
</div>
</div>
<script>
function app(){
return {
darkMode: 1,
fontSize: 9,
fontStyle: 'normal',
color: 'blue',
selectedFont: "Alfa Slab One",
googleFonts: [
"ABeeZee",
"Abel",
"Abhaya Libre",
"Abril Fatface",
"Aclonica",
"Acme",
"Actor",
"Adamina",
"Advent Pro",
"Aguafina Script",
"Akronim",
"Aladin",
"Aldrich",
"Alef",
"Alegreya",
"Alegreya SC",
"Alegreya Sans",
"Alegreya Sans SC",
"Alex Brush",
"Alfa Slab One",
"Alice",
"Alike",
"Alike Angular",
"Allan",
"Allerta",
"Allerta Stencil",
"Allura",
"Almendra",
"Almendra Display",
"Almendra SC",
"Amarante",
"Amaranth",
"Amatic SC",
"Amatica SC",
"Amethysta",
"Amiko",
"Amiri",
"Amita",
"Anaheim",
"Andada",
"Andika",
"Angkor",
"Annie Use Your Telescope",
"Anonymous Pro",
"Antic",
"Antic Didone",
"Antic Slab",
"Anton",
"Arapey",
"Arbutus",
"Arbutus Slab",
"Architects Daughter",
"Archivo Black",
"Archivo Narrow",
"Aref Ruqaa",
"Arima Madurai",
"Arimo",
"Arizonia",
"Armata",
"Artifika",
"Arvo",
"Arya",
"Asap",
"Asar",
"Asset",
"Assistant",
"Astloch",
"Asul",
"Athiti",
"Atma",
"Atomic Age",
"Aubrey",
"Audiowide",
"Autour One",
"Average",
"Average Sans",
"Averia Gruesa Libre",
"Averia Libre",
"Averia Sans Libre",
"Averia Serif Libre",
"Bad Script",
"Baloo",
"Baloo Bhai",
"Baloo Bhaina",
"Baloo Chettan",
"Baloo Da",
"Baloo Paaji",
"Baloo Tamma",
"Baloo Thambi",
"Balthazar",
"Bangers",
"Basic",
"Battambang",
"Baumans",
"Bayon",
"Belgrano",
"Belleza",
"BenchNine",
"Bentham",
"Berkshire Swash",
"Bevan",
"Bigelow Rules",
"Bigshot One",
"Bilbo",
"Bilbo Swash Caps",
"BioRhyme",
"BioRhyme Expanded",
"Biryani",
"Bitter",
"Black Ops One",
"Bokor",
"Bonbon",
"Boogaloo",
"Bowlby One",
"Bowlby One SC",
"Brawler",
"Bree Serif",
"Bubblegum Sans",
"Bubbler One",
"Buda",
"Buenard",
"Bungee",
"Bungee Hairline",
"Bungee Inline",
"Bungee Outline",
"Bungee Shade",
"Butcherman",
"Butterfly Kids",
"Cabin",
"Cabin Condensed",
"Cabin Sketch",
"Caesar Dressing",
"Cagliostro",
"Cairo",
"Calligraffitti",
"Cambay",
"Cambo",
"Candal",
"Cantarell",
"Cantata One",
"Cantora One",
"Capriola",
"Cardo",
"Carme",
"Carrois Gothic",
"Carrois Gothic SC",
"Carter One",
"Catamaran",
"Caudex",
"Caveat",
"Caveat Brush",
"Cedarville Cursive",
"Ceviche One",
"Changa",
"Changa One",
"Chango",
"Chathura",
"Chau Philomene One",
"Chela One",
"Chelsea Market",
"Chenla",
"Cherry Cream Soda",
"Cherry Swash",
"Chewy",
"Chicle",
"Chivo",
"Chonburi",
"Cinzel",
"Cinzel Decorative",
"Clicker Script",
"Coda",
"Coda Caption",
"Codystar",
"Coiny",
"Combo",
"Comfortaa",
"Coming Soon",
"Concert One",
"Condiment",
"Content",
"Contrail One",
"Convergence",
"Cookie",
"Copse",
"Corben",
"Cormorant",
"Cormorant Garamond",
"Cormorant Infant",
"Cormorant SC",
"Cormorant Unicase",
"Cormorant Upright",
"Courgette",
"Cousine",
"Coustard",
"Covered By Your Grace",
"Crafty Girls",
"Creepster",
"Crete Round",
"Crimson Text",
"Croissant One",
"Crushed",
"Cuprum",
"Cutive",
"Cutive Mono",
"Damion",
"Dancing Script",
"Dangrek",
"David Libre",
"Dawning of a New Day",
"Days One",
"Dekko",
"Delius",
"Delius Swash Caps",
"Delius Unicase",
"Della Respira",
"Denk One",
"Devonshire",
"Dhurjati",
"Didact Gothic",
"Diplomata",
"Diplomata SC",
"Domine",
"Donegal One",
"Doppio One",
"Dorsa",
"Dosis",
"Dr Sugiyama",
"Droid Sans",
"Droid Sans Mono",
"Droid Serif",
"Duru Sans",
"Dynalight",
"EB Garamond",
"Eagle Lake",
"Eater",
"Economica",
"Eczar",
"Ek Mukta",
"El Messiri",
"Electrolize",
"Elsie",
"Elsie Swash Caps",
"Emblema One",
"Emilys Candy",
"Engagement",
"Englebert",
"Enriqueta",
"Erica One",
"Esteban",
"Euphoria Script",
"Ewert",
"Exo",
"Exo 2",
"Expletus Sans",
"Fanwood Text",
"Farsan",
"Fascinate",
"Fascinate Inline",
"Faster One",
"Fasthand",
"Fauna One",
"Federant",
"Federo",
"Felipa",
"Fenix",
"Finger Paint",
"Fira Mono",
"Fira Sans",
"Fjalla One",
"Fjord One",
"Flamenco",
"Flavors",
"Fondamento",
"Fontdiner Swanky",
"Forum",
"Francois One",
"Frank Ruhl Libre",
"Freckle Face",
"Fredericka the Great",
"Fredoka One",
"Freehand",
"Fresca",
"Frijole",
"Fruktur",
"Fugaz One",
"GFS Didot",
"GFS Neohellenic",
"Gabriela",
"Gafata",
"Galada",
"Galdeano",
"Galindo",
"Gentium Basic",
"Gentium Book Basic",
"Geo",
"Geostar",
"Geostar Fill",
"Germania One",
"Gidugu",
"Gilda Display",
"Give You Glory",
"Glass Antiqua",
"Glegoo",
"Gloria Hallelujah",
"Goblin One",
"Gochi Hand",
"Gorditas",
"Goudy Bookletter 1911",
"Graduate",
"Grand Hotel",
"Gravitas One",
"Great Vibes",
"Griffy",
"Gruppo",
"Gudea",
"Gurajada",
"Habibi",
"Halant",
"Hammersmith One",
"Hanalei",
"Hanalei Fill",
"Handlee",
"Hanuman",
"Happy Monkey",
"Harmattan",
"Headland One",
"Heebo",
"Henny Penny",
"Herr Von Muellerhoff",
"Hind",
"Hind Guntur",
"Hind Madurai",
"Hind Siliguri",
"Hind Vadodara",
"Holtwood One SC",
"Homemade Apple",
"Homenaje",
"IM Fell DW Pica",
"IM Fell DW Pica SC",
"IM Fell Double Pica",
"IM Fell Double Pica SC",
"IM Fell English",
"IM Fell English SC",
"IM Fell French Canon",
"IM Fell French Canon SC",
"IM Fell Great Primer",
"IM Fell Great Primer SC",
"Iceberg",
"Iceland",
"Imprima",
"Inconsolata",
"Inder",
"Indie Flower",
"Inika",
"Inknut Antiqua",
"Irish Grover",
"Istok Web",
"Italiana",
"Italianno",
"Itim",
"Jacques Francois",
"Jacques Francois Shadow",
"Jaldi",
"Jim Nightshade",
"Jockey One",
"Jolly Lodger",
"Jomhuria",
"Josefin Sans",
"Josefin Slab",
"Joti One",
"Judson",
"Julee",
"Julius Sans One",
"Junge",
"Jura",
"Just Another Hand",
"Just Me Again Down Here",
"Kadwa",
"Kalam",
"Kameron",
"Kanit",
"Kantumruy",
"Karla",
"Karma",
"Katibeh",
"Kaushan Script",
"Kavivanar",
"Kavoon",
"Kdam Thmor",
"Keania One",
"Kelly Slab",
"Kenia",
"Khand",
"Khmer",
"Khula",
"Kite One",
"Knewave",
"Kotta One",
"Koulen",
"Kranky",
"Kreon",
"Kristi",
"Krona One",
"Kumar One",
"Kumar One Outline",
"Kurale",
"La Belle Aurore",
"Laila",
"Lakki Reddy",
"Lalezar",
"Lancelot",
"Lateef",
"Lato",
"League Script",
"Leckerli One",
"Ledger",
"Lekton",
"Lemon",
"Lemonada",
"Libre Baskerville",
"Libre Franklin",
"Life Savers",
"Lilita One",
"Lily Script One",
"Limelight",
"Linden Hill",
"Lobster",
"Lobster Two",
"Londrina Outline",
"Londrina Shadow",
"Londrina Sketch",
"Londrina Solid",
"Lora",
"Love Ya Like A Sister",
"Loved by the King",
"Lovers Quarrel",
"Luckiest Guy",
"Lusitana",
"Lustria",
"Macondo",
"Macondo Swash Caps",
"Mada",
"Magra",
"Maiden Orange",
"Maitree",
"Mako",
"Mallanna",
"Mandali",
"Marcellus",
"Marcellus SC",
"Marck Script",
"Margarine",
"Marko One",
"Marmelad",
"Martel",
"Martel Sans",
"Marvel",
"Mate",
"Mate SC",
"Maven Pro",
"McLaren",
"Meddon",
"MedievalSharp",
"Medula One",
"Meera Inimai",
"Megrim",
"Meie Script",
"Merienda",
"Merienda One",
"Merriweather",
"Merriweather Sans",
"Metal",
"Metal Mania",
"Metamorphous",
"Metrophobic",
"Michroma",
"Milonga",
"Miltonian",
"Miltonian Tattoo",
"Miniver",
"Miriam Libre",
"Mirza",
"Miss Fajardose",
"Mitr",
"Modak",
"Modern Antiqua",
"Mogra",
"Molengo",
"Molle",
"Monda",
"Monofett",
"Monoton",
"Monsieur La Doulaise",
"Montaga",
"Montez",
"Montserrat",
"Montserrat Alternates",
"Montserrat Subrayada",
"Moul",
"Moulpali",
"Mountains of Christmas",
"Mouse Memoirs",
"Mr Bedfort",
"Mr Dafoe",
"Mr De Haviland",
"Mrs Saint Delafield",
"Mrs Sheppards",
"Mukta Vaani",
"Muli",
"Mystery Quest",
"NTR",
"Neucha",
"Neuton",
"New Rocker",
"News Cycle",
"Niconne",
"Nixie One",
"Nobile",
"Nokora",
"Norican",
"Nosifer",
"Nothing You Could Do",
"Noticia Text",
"Noto Sans",
"Noto Serif",
"Nova Cut",
"Nova Flat",
"Nova Mono",
"Nova Oval",
"Nova Round",
"Nova Script",
"Nova Slim",
"Nova Square",
"Numans",
"Nunito",
"Nunito Sans",
"Odor Mean Chey",
"Offside",
"Old Standard TT",
"Oldenburg",
"Oleo Script",
"Oleo Script Swash Caps",
"Open Sans",
"Open Sans Condensed",
"Oranienbaum",
"Orbitron",
"Oregano",
"Orienta",
"Original Surfer",
"Oswald",
"Over the Rainbow",
"Overlock",
"Overlock SC",
"Ovo",
"Oxygen",
"Oxygen Mono",
"PT Mono",
"PT Sans",
"PT Sans Caption",
"PT Sans Narrow",
"PT Serif",
"PT Serif Caption",
"Pacifico",
"Palanquin",
"Palanquin Dark",
"Paprika",
"Parisienne",
"Passero One",
"Passion One",
"Pathway Gothic One",
"Patrick Hand",
"Patrick Hand SC",
"Pattaya",
"Patua One",
"Pavanam",
"Paytone One",
"Peddana",
"Peralta",
"Permanent Marker",
"Petit Formal Script",
"Petrona",
"Philosopher",
"Piedra",
"Pinyon Script",
"Pirata One",
"Plaster",
"Play",
"Playball",
"Playfair Display",
"Playfair Display SC",
"Podkova",
"Poiret One",
"Poller One",
"Poly",
"Pompiere",
"Pontano Sans",
"Poppins",
"Port Lligat Sans",
"Port Lligat Slab",
"Pragati Narrow",
"Prata",
"Preahvihear",
"Press Start 2P",
"Pridi",
"Princess Sofia",
"Prociono",
"Prompt",
"Prosto One",
"Proza Libre",
"Puritan",
"Purple Purse",
"Quando",
"Quantico",
"Quattrocento",
"Quattrocento Sans",
"Questrial",
"Quicksand",
"Quintessential",
"Qwigley",
"Racing Sans One",
"Radley",
"Rajdhani",
"Rakkas",
"Raleway",
"Raleway Dots",
"Ramabhadra",
"Ramaraja",
"Rambla",
"Rammetto One",
"Ranchers",
"Rancho",
"Ranga",
"Rasa",
"Rationale",
"Ravi Prakash",
"Redressed",
"Reem Kufi",
"Reenie Beanie",
"Revalia",
"Rhodium Libre",
"Ribeye",
"Ribeye Marrow",
"Righteous",
"Risque",
"Roboto",
"Roboto Condensed",
"Roboto Mono",
"Roboto Slab",
"Rochester",
"Rock Salt",
"Rokkitt",
"Romanesco",
"Ropa Sans",
"Rosario",
"Rosarivo",
"Rouge Script",
"Rozha One",
"Rubik",
"Rubik Mono One",
"Rubik One",
"Ruda",
"Rufina",
"Ruge Boogie",
"Ruluko",
"Rum Raisin",
"Ruslan Display",
"Russo One",
"Ruthie",
"Rye",
"Sacramento",
"Sahitya",
"Sail",
"Salsa",
"Sanchez",
"Sancreek",
"Sansita One",
"Sarala",
"Sarina",
"Sarpanch",
"Satisfy",
"Scada",
"Scheherazade",
"Schoolbell",
"Scope One",
"Seaweed Script",
"Secular One",
"Sevillana",
"Seymour One",
"Shadows Into Light",
"Shadows Into Light Two",
"Shanti",
"Share",
"Share Tech",
"Share Tech Mono",
"Shojumaru",
"Short Stack",
"Shrikhand",
"Siemreap",
"Sigmar One",
"Signika",
"Signika Negative",
"Simonetta",
"Sintony",
"Sirin Stencil",
"Six Caps",
"Skranji",
"Slabo 13px",
"Slabo 27px",
"Slackey",
"Smokum",
"Smythe",
"Sniglet",
"Snippet",
"Snowburst One",
"Sofadi One",
"Sofia",
"Sonsie One",
"Sorts Mill Goudy",
"Source Code Pro",
"Source Sans Pro",
"Source Serif Pro",
"Space Mono",
"Special Elite",
"Spicy Rice",
"Spinnaker",
"Spirax",
"Squada One",
"Sree Krushnadevaraya",
"Sriracha",
"Stalemate",
"Stalinist One",
"Stardos Stencil",
"Stint Ultra Condensed",
"Stint Ultra Expanded",
"Stoke",
"Strait",
"Sue Ellen Francisco",
"Suez One",
"Sumana",
"Sunshiney",
"Supermercado One",
"Sura",
"Suranna",
"Suravaram",
"Suwannaphum",
"Swanky and Moo Moo",
"Syncopate",
"Tangerine",
"Taprom",
"Tauri",
"Taviraj",
"Teko",
"Telex",
"Tenali Ramakrishna",
"Tenor Sans",
"Text Me One",
"The Girl Next Door",
"Tienne",
"Tillana",
"Timmana",
"Tinos",
"Titan One",
"Titillium Web",
"Trade Winds",
"Trirong",
"Trocchi",
"Trochut",
"Trykker",
"Tulpen One",
"Ubuntu",
"Ubuntu Condensed",
"Ubuntu Mono",
"Ultra",
"Uncial Antiqua",
"Underdog",
"Unica One",
"UnifrakturCook",
"UnifrakturMaguntia",
"Unkempt",
"Unlock",
"Unna",
"VT323",
"Vampiro One",
"Varela",
"Varela Round",
"Vast Shadow",
"Vesper Libre",
"Vibur",
"Vidaloka",
"Viga",
"Voces",
"Volkhov",
"Vollkorn",
"Voltaire",
"Waiting for the Sunrise",
"Wallpoet",
"Walter Turncoat",
"Warnes",
"Wellfleet",
"Wendy One",
"Wire One",
"Work Sans",
"Yanone Kaffeesatz",
"Yantramanav",
"Yatra One",
"Yellowtail",
"Yeseva One",
"Yesteryear",
"Yrsa",
"Zeyada",
],
}
}
</script>
<!-- BUY ME A BEER AND HELP SUPPORT OPEN-SOURCE RESOURCES -->
<div class="flex items-end justify-end fixed bottom-0 right-0 mb-4 mr-4 z-10">
<div>
<a title="Buy me a beer" href="https://www.buymeacoffee.com/scottwindon" target="_blank" class="block w-16 h-16 rounded-full transition-all shadow hover:shadow-lg transform hover:scale-110 hover:rotate-12">
<img class="object-cover object-center w-full h-full rounded-full" src="https://i.pinimg.com/originals/60/fd/e8/60fde811b6be57094e0abc69d9c2622a.jpg"/>
</a>
</div>
</div>
How to create a Font Preview with Tailwind CSS?
Install tailwind css of verion 2.0.2
Use the script
html tag to import the script of Tailwind CSS of the version 2.0.2
<script src="https://cdn.tailwindcss.com"></script>
All the unility class needed to create a Font Preview component
min-w-screen
min-h-screen
bg-gray-800
flex
px-5
py-5
w-full
mx-auto
bg-white
text-gray-700
max-w-4xl
md:flex
md:w-1/2
p-10
text-center
bg-white
text-lg
mt-8
relative
inline-block
w-10
mr-2
absolute
block
w-4
h-4
mt-1
mx-1
border-none
overflow-hidden
h-6
bg-gray-900
bg-opacity-20
px-10
py-14
mb-3
text-xs
ml-1
text-gray-400
pl-1
mb-1
border-b-2
border-gray-200
focus:border-indigo-500
mb-4
mb-2
h-10
text-blue-500
bg-blue-500
border-white
text-indigo-500
bg-indigo-500
text-red-500
bg-red-500
text-yellow-500
bg-yellow-500
text-green-500
bg-green-500
text-gray-500
bg-gray-500
fixed
bottom-0
right-0
mr-4
z-10
w-16
h-16
h-full
68 steps to create a Font Preview component with Tailwind CSS
Set the minimum width/height of an element using the
min-w-screen
utilities.Set the minimum width/height of an element using the
min-h-screen
utilities.Control the background color of an element to gray-800 using the
bg-gray-800
utilities.Use
flex
to create a block-level flex container.Control the horizontal padding of an element to 1.25rem using the
px-5
utilities.Control the vertical padding of an element to 1.25rem using the
py-5
utilities.Use
w-full
to set an element to a 100% based width.Control the horizontal margin of an element to auto using the
mx-auto
utilities.Control the background color of an element to white using the
bg-white
utilities.Control the text color of an element to gray-700 using the
text-gray-700
utilities.Set the maximum width/height of an element using the
max-w-4xl
utilities.Use
flex
to create a block-level flex container at only medium screen sizes.Use
md:w-1/2
to set an element to a fixed width(1/2) at only medium screen sizes.Control the padding on all sides of an element to 2.5rem using the
p-10
utilities.Control the text color of an element to center using the
text-center
utilities.Control the background color of an element to white using the
bg-white
utilities.Control the text color of an element to lg using the
text-lg
utilities.Control the margin on top side of an element to 2rem using the
mt-8
utilities.Use
relative
to position an element according to the normal flow of the document.Use
inline-block
utilities to wrap the element to prevent the text inside from extending beyond its parent.Use
w-10
to set an element to a fixed width(2.5rem).Control the margin on right side of an element to 0.5rem using the
mr-2
utilities.Use
absolute
to position an element outside of the normal flow of the document, causing neighboring elements to act as if the element doesn’t exist.Use
inline
utilities to put the element on its own line and fill its parent.Use
w-4
to set an element to a fixed width(1rem).Use
h-4
to set an element to a fixed height(1rem).Control the margin on top side of an element to 0.25rem using the
mt-1
utilities.Control the horizontal margin of an element to 0.25rem using the
mx-1
utilities.Control the border color of an element to none using the
border-none
utilities.Use
overflow-hidden
to clip any content within an element that overflows the bounds of that element.Use
h-6
to set an element to a fixed height(1.5rem).Control the background color of an element to gray-900 using the
bg-gray-900
utilities.Control the background color of an element to opacity-20 using the
bg-opacity-20
utilities.Control the horizontal padding of an element to 2.5rem using the
px-10
utilities.Control the vertical padding of an element to 3.5rem using the
py-14
utilities.Control the margin on bottom side of an element to 0.75rem using the
mb-3
utilities.Control the text color of an element to xs using the
text-xs
utilities.Control the margin on left side of an element to 0.25rem using the
ml-1
utilities.Control the text color of an element to gray-400 using the
text-gray-400
utilities.Set the left padding of the element to 0.25rem using the
pl-1
utilities classControl the margin on bottom side of an element to 0.25rem using the
mb-1
utilities.Control the border color of an element to b-2 using the
border-b-2
utilities.Control the border color of an element to gray-200 using the
border-gray-200
utilities.Control the border color of an element to indigo-500 using the
focus:border-indigo-500
utilities on focus.Control the margin on bottom side of an element to 1rem using the
mb-4
utilities.Control the margin on bottom side of an element to 0.5rem using the
mb-2
utilities.Use
h-10
to set an element to a fixed height(2.5rem).Control the text color of an element to blue-500 using the
text-blue-500
utilities.Control the background color of an element to blue-500 using the
bg-blue-500
utilities.Control the border color of an element to white using the
border-white
utilities.Control the text color of an element to indigo-500 using the
text-indigo-500
utilities.Control the background color of an element to indigo-500 using the
bg-indigo-500
utilities.Control the text color of an element to red-500 using the
text-red-500
utilities.Control the background color of an element to red-500 using the
bg-red-500
utilities.Control the text color of an element to yellow-500 using the
text-yellow-500
utilities.Control the background color of an element to yellow-500 using the
bg-yellow-500
utilities.Control the text color of an element to green-500 using the
text-green-500
utilities.Control the background color of an element to green-500 using the
bg-green-500
utilities.Control the text color of an element to gray-500 using the
text-gray-500
utilities.Control the background color of an element to gray-500 using the
bg-gray-500
utilities.Use
fixed
to position an element relative to the browser window.Use the
bottom-0
utilities to set the bottom position of a positioned element to 0rem.Use the
right-0
utilities to set the right position of a positioned element to 0rem.Control the margin on right side of an element to 1rem using the
mr-4
utilities.Control the stack order (or three-dimensional positioning) of an element to 10 in Tailwind, regardless of order it has been displayed, using the
z-10
utilities.Use
w-16
to set an element to a fixed width(4rem).Use
h-16
to set an element to a fixed height(4rem).Use
h-full
to set an element’s height to 100% of its parent, as long as the parent has a defined height.
Conclusion
The above is a step-by-step tutorial on how to use Tailwind CSS to create a Font Preview components, learn and follow along to implement your own components.