- Published on
A Complete Guide To Create A Product Detail Page With TailwindCSS 2.0 With Tailwind CSS

- What is Tailwind CSS?
- The description of Product Detail Page With TailwindCSS 2.0 ui component
- Why use Tailwind CSS to create a Product Detail Page With TailwindCSS 2.0 ui component?
- The preview of Product Detail Page With TailwindCSS 2.0 ui component
- The source code of Product Detail Page With TailwindCSS 2.0 ui component
- How to create a Product Detail Page With TailwindCSS 2.0 with Tailwind CSS?
- Install tailwind css of verion 1.9.6
- All the unility class needed to create a Product Detail Page With TailwindCSS 2.0 component
- 95 steps to create a Product Detail Page With TailwindCSS 2.0 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 Product Detail Page With TailwindCSS 2.0 ui component
Why use Tailwind CSS to create a Product Detail Page With TailwindCSS 2.0 ui component?
- It can make the building process of Product Detail Page With TailwindCSS 2.0 ui component faster and more easily.
- Enables building complex responsive layouts and components freely.
- Minimum lines of CSS code in Product Detail Page With TailwindCSS 2.0 component file.
The preview of Product Detail Page With TailwindCSS 2.0 ui component
Free download of the Product Detail Page With TailwindCSS 2.0's source code
The source code of Product Detail Page With TailwindCSS 2.0 ui component
<!-- This is an example component -->
<div>
<!DOCTYPE html>
<html lang="en" >
<head>
<meta charset="UTF-8">
<title>CodePen - Product Page with TailwindCSS</title>
<link rel='stylesheet' href='https://cdn.jsdelivr.net/npm/[email protected]/dist/tailwind.min.css'>
<link rel='stylesheet' href='https://fonts.googleapis.com/css2?family=Rubik:ital,[email protected],400;0,600;0,700;1,400&display=swap'><link rel="stylesheet" href="./style.css">
</head>
<body class="antialiased">
<div class="bg-indigo-700 text-indigo-200 md:text-center py-2 px-4">
Inspired from Dribbble Shot by <a href="https://dribbble.com/shots/14127375-Product-Page" class="font-bold underline hover:text-indigo-100">Vishnu Prasad</a>.
See his works on <a href="https://dribbble.com/vlockn" class="font-bold underline hover:text-indigo-100">Dribbble</a>.
</div>
<div class="bg-white shadow-sm sticky top-0">
<div class="max-w-7xl mx-auto px-4 sm:px-6 lg:px-8 py-1 md:py-4">
<div class="flex items-center justify-between md:justify-start">
<!-- Menu Trigger -->
<button type="button" class="md:hidden w-10 h-10 rounded-lg -ml-2 flex justify-center items-center">
<svg class="text-gray-500 w-6 h-6" xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 24 24" stroke="currentColor">
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M4 6h16M4 12h16M4 18h16" />
</svg>
</button>
<!-- ./ Menu Trigger -->
<a href="#" class="font-bold text-gray-700 text-2xl">Shop.</a>
<div class="hidden md:flex space-x-3 flex-1 lg:ml-8">
<a href="#" class="px-2 py-2 hover:bg-gray-100 rounded-lg text-gray-400 hover:text-gray-600">Electronics</a>
<a href="#" class="px-2 py-2 hover:bg-gray-100 rounded-lg text-gray-400 hover:text-gray-600">Fashion</a>
<a href="#" class="px-2 py-2 hover:bg-gray-100 rounded-lg text-gray-400 hover:text-gray-600">Tools</a>
<a href="#" class="px-2 py-2 hover:bg-gray-100 rounded-lg text-gray-400 hover:text-gray-600">Books</a>
<a href="#" class="px-2 py-2 hover:bg-gray-100 rounded-lg text-gray-400 hover:text-gray-600">More</a>
</div>
<div class="flex items-center space-x-4">
<div class="relative hidden md:block">
<input type="search" class="pl-10 pr-2 h-10 py-1 rounded-lg border border-gray-200 focus:border-gray-300 focus:outline-none focus:shadow-inner leading-none" placeholder="Search">
<svg class="h-6 w-6 text-gray-300 ml-2 mt-2 stroke-current absolute top-0 left-0" xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 24 24" stroke="currentColor">
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M21 21l-6-6m2-5a7 7 0 11-14 0 7 7 0 0114 0z" />
</svg>
</div>
<a href="#" class="flex h-10 items-center px-2 rounded-lg border border-gray-200 hover:border-gray-300 focus:outline-none hover:shadow-inner">
<svg class="h-6 w-6 leading-none text-gray-300 stroke-current" xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 24 24" stroke="currentColor">
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M16 11V7a4 4 0 00-8 0v4M5 9h14l1 12H4L5 9z" />
</svg>
<span class="pl-1 text-gray-500 text-md">0</span>
</a>
<button type="button" class="hidden md:block w-10 h-10 rounded-lg bg-gray-100 border border-gray-200 flex justify-center items-center">
<img src="https://avatars.dicebear.com/api/bottts/2.svg" alt="bottts" width="28" height="28" class="rounded-lg mx-auto">
</button>
</div>
</div>
<!-- Search Mobile -->
<div class="relative md:hidden">
<input type="search" class="mt-1 w-full pl-10 pr-2 h-10 py-1 rounded-lg border border-gray-200 focus:border-gray-300 focus:outline-none focus:shadow-inner leading-none" placeholder="Search">
<svg class="h-6 w-6 text-gray-300 ml-2 mt-3 stroke-current absolute top-0 left-0" xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 24 24" stroke="currentColor">
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M21 21l-6-6m2-5a7 7 0 11-14 0 7 7 0 0114 0z" />
</svg>
</div>
<!-- ./ Search Mobile -->
</div>
</div>
<div class="py-6">
<!-- Breadcrumbs -->
<div class="max-w-7xl mx-auto px-4 sm:px-6 lg:px-8">
<div class="flex items-center space-x-2 text-gray-400 text-sm">
<a href="#" class="hover:underline hover:text-gray-600">Home</a>
<span>
<svg class="h-5 w-5 leading-none text-gray-300" xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 24 24" stroke="currentColor">
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M9 5l7 7-7 7" />
</svg>
</span>
<a href="#" class="hover:underline hover:text-gray-600">Electronics</a>
<span>
<svg class="h-5 w-5 leading-none text-gray-300" xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 24 24" stroke="currentColor">
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M9 5l7 7-7 7" />
</svg>
</span>
<span>Headphones</span>
</div>
</div>
<!-- ./ Breadcrumbs -->
<div class="max-w-7xl mx-auto px-4 sm:px-6 lg:px-8 mt-6">
<div class="flex flex-col md:flex-row -mx-4">
<div class="md:flex-1 px-4">
<div x-data="{ image: 1 }" x-cloak>
<div class="h-64 md:h-80 rounded-lg bg-gray-100 mb-4">
<div x-show="image === 1" class="h-64 md:h-80 rounded-lg bg-gray-100 mb-4 flex items-center justify-center">
<span class="text-5xl">1</span>
</div>
<div x-show="image === 2" class="h-64 md:h-80 rounded-lg bg-gray-100 mb-4 flex items-center justify-center">
<span class="text-5xl">2</span>
</div>
<div x-show="image === 3" class="h-64 md:h-80 rounded-lg bg-gray-100 mb-4 flex items-center justify-center">
<span class="text-5xl">3</span>
</div>
<div x-show="image === 4" class="h-64 md:h-80 rounded-lg bg-gray-100 mb-4 flex items-center justify-center">
<span class="text-5xl">4</span>
</div>
</div>
<div class="flex -mx-2 mb-4">
<template x-for="i in 4">
<div class="flex-1 px-2">
<button x-on:click="image = i" :class="{ 'ring-2 ring-indigo-300 ring-inset': image === i }" class="focus:outline-none w-full rounded-lg h-24 md:h-32 bg-gray-100 flex items-center justify-center">
<span x-text="i" class="text-2xl"></span>
</button>
</div>
</template>
</div>
</div>
</div>
<div class="md:flex-1 px-4">
<h2 class="mb-2 leading-tight tracking-tight font-bold text-gray-800 text-2xl md:text-3xl">Lorem ipsum dolor, sit amet consectetur, adipisicing elit.</h2>
<p class="text-gray-500 text-sm">By <a href="#" class="text-indigo-600 hover:underline">ABC Company</a></p>
<div class="flex items-center space-x-4 my-4">
<div>
<div class="rounded-lg bg-gray-100 flex py-2 px-3">
<span class="text-indigo-400 mr-1 mt-1">$</span>
<span class="font-bold text-indigo-600 text-3xl">25</span>
</div>
</div>
<div class="flex-1">
<p class="text-green-500 text-xl font-semibold">Save 12%</p>
<p class="text-gray-400 text-sm">Inclusive of all Taxes.</p>
</div>
</div>
<p class="text-gray-500">Lorem ipsum, dolor sit, amet consectetur adipisicing elit. Vitae exercitationem porro saepe ea harum corrupti vero id laudantium enim, libero blanditiis expedita cupiditate a est.</p>
<div class="flex py-4 space-x-4">
<div class="relative">
<div class="text-center left-0 pt-2 right-0 absolute block text-xs uppercase text-gray-400 tracking-wide font-semibold">Qty</div>
<select class="cursor-pointer appearance-none rounded-xl border border-gray-200 pl-4 pr-8 h-14 flex items-end pb-1">
<option>1</option>
<option>2</option>
<option>3</option>
<option>4</option>
<option>5</option>
</select>
<svg class="w-5 h-5 text-gray-400 absolute right-0 bottom-0 mb-2 mr-2" xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 24 24" stroke="currentColor">
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M8 9l4-4 4 4m0 6l-4 4-4-4" />
</svg>
</div>
<button type="button" class="h-14 px-6 py-2 font-semibold rounded-xl bg-indigo-600 hover:bg-indigo-500 text-white">
Add to Cart
</button>
</div>
</div>
</div>
</div>
</div>
</body>
<!-- partial -->
<script src='https://cdn.jsdelivr.net/gh/alpinejs/[email protected]/dist/alpine.min.js'></script>
</html>
</div>
How to create a Product Detail Page With TailwindCSS 2.0 with Tailwind CSS?
Install tailwind css of verion 1.9.6
Use the link
html tag to import the stylesheet of Tailwind CSS of the version 1.9.6
<link href=https://unpkg.com/[email protected]/dist/tailwind.min.css rel="stylesheet">
All the unility class needed to create a Product Detail Page With TailwindCSS 2.0 component
bg-indigo-700
text-indigo-200
md:text-center
py-2
px-4
hover:text-indigo-100
bg-white
sticky
top-0
max-w-7xl
mx-auto
sm:px-6
lg:px-8
py-1
md:py-4
flex
md:justify-start
md:hidden
w-10
h-10
-ml-2
text-gray-500
w-6
h-6
text-gray-700
text-2xl
hidden
md:flex
flex-1
lg:ml-8
px-2
hover:bg-gray-100
text-gray-400
hover:text-gray-600
relative
md:block
pl-10
pr-2
border-gray-200
focus:border-gray-300
text-gray-300
ml-2
mt-2
absolute
left-0
hover:border-gray-300
pl-1
text-md
bg-gray-100
mt-1
w-full
mt-3
py-6
text-sm
h-5
w-5
mt-6
flex-col
md:flex-row
-mx-4
md:flex-1
h-64
md:h-80
mb-4
text-5xl
-mx-2
h-24
md:h-32
mb-2
text-gray-800
md:text-3xl
text-indigo-600
my-4
px-3
text-indigo-400
mr-1
text-3xl
text-green-500
text-xl
py-4
text-center
pt-2
right-0
block
text-xs
pl-4
pr-8
h-14
pb-1
bottom-0
mr-2
px-6
bg-indigo-600
hover:bg-indigo-500
text-white
95 steps to create a Product Detail Page With TailwindCSS 2.0 component with Tailwind CSS
Control the background color of an element to indigo-700 using the
bg-indigo-700
utilities.Control the text color of an element to indigo-200 using the
text-indigo-200
utilities.Control the text color of an element to center at only medium screen sizes using the
md:text-center
utilities.Control the vertical padding of an element to 0.5rem using the
py-2
utilities.Control the horizontal padding of an element to 1rem using the
px-4
utilities.Control the text color of an element to indigo-100 on hover using the
hover:text-indigo-100
utilities.Control the background color of an element to white using the
bg-white
utilities.Use
sticky
to position an element asrelative
until it crosses a specified threshold, then treat it as fixed until its parent is off screen.Use the
top-0
utilities to set the top position of a positioned element to 0rem.Set the maximum width/height of an element using the
max-w-7xl
utilities.Control the horizontal margin of an element to auto using the
mx-auto
utilities.Control the horizontal padding of an element to 1.5rem at only small screen sizes using the
sm:px-6
utilities.Control the horizontal padding of an element to 2rem at only large screen sizes using the
lg:px-8
utilities.Control the vertical padding of an element to 0.25rem using the
py-1
utilities.Control the vertical padding of an element to 1rem at only medium screen sizes using the
md:py-4
utilities.Use
flex
to create a block-level flex container.Use
justify-start
to justify items against the start of the container’s main axis at only medium screen sizes.Use
hidden
to set an element to display: none and remove it from the page layout at only medium screen sizes.Use
w-10
to set an element to a fixed width(2.5rem).Use
h-10
to set an element to a fixed height(2.5rem).Control the margin on left side of an element to -0.5rem using the
-ml-2
utilities.Control the text color of an element to gray-500 using the
text-gray-500
utilities.Use
w-6
to set an element to a fixed width(1.5rem).Use
h-6
to set an element to a fixed height(1.5rem).Control the text color of an element to gray-700 using the
text-gray-700
utilities.Control the text color of an element to 2xl using the
text-2xl
utilities.Use
hidden
to set an element to display: none and remove it from the page layout.Use
flex
to create a block-level flex container at only medium screen sizes.Use
flex
to create a block-level flex container.Control the margin on left side of an element to 2rem at only large screen sizes using the
lg:ml-8
utilities.Control the horizontal padding of an element to 0.5rem using the
px-2
utilities.Control the background color of an element to gray-100 using the
hover:bg-gray-100
utilities on hover.Control the text color of an element to gray-400 using the
text-gray-400
utilities.Control the text color of an element to gray-600 on hover using the
hover:text-gray-600
utilities.Use
relative
to position an element according to the normal flow of the document.Use
inline
utilities to put the element on its own line and fill its parent at only medium screen sizes.Adjust the left padding of an element to 2.5rem using the
pl-10
utilities classControl the padding on right side of an element to 0.5rem using the
pr-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 gray-300 using the
focus:border-gray-300
utilities on focus.Control the text color of an element to gray-300 using the
text-gray-300
utilities.Control the margin on left side of an element to 0.5rem using the
ml-2
utilities.Control the margin on top side of an element to 0.5rem using the
mt-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 the
left-0
utilities to set the left position of a positioned element to 0rem.Control the border color of an element to gray-300 using the
hover:border-gray-300
utilities on hover.Adjust the left padding of an element to 0.25rem using the
pl-1
utilities classControl the text color of an element to md using the
text-md
utilities.Control the background color of an element to gray-100 using the
bg-gray-100
utilities.Control the margin on top side of an element to 0.25rem using the
mt-1
utilities.Use
w-full
to set an element to a 100% based width.Control the margin on top side of an element to 0.75rem using the
mt-3
utilities.Control the vertical padding of an element to 1.5rem using the
py-6
utilities.Control the text color of an element to sm using the
text-sm
utilities.Use
h-5
to set an element to a fixed height(1.25rem).Use
w-5
to set an element to a fixed width(1.25rem).Control the margin on top side of an element to 1.5rem using the
mt-6
utilities.Use
flex
to create a block-level flex container.Use
flex
to create a block-level flex container at only medium screen sizes.Control the horizontal margin of an element to -1rem using the
-mx-4
utilities.Use
flex
to create a block-level flex container at only medium screen sizes.Use
h-64
to set an element to a fixed height(16rem).Use
md:h-80
to set an element to a fixed height(20rem) at only medium screen sizes.Control the margin on bottom side of an element to 1rem using the
mb-4
utilities.Control the text color of an element to 5xl using the
text-5xl
utilities.Control the horizontal margin of an element to -0.5rem using the
-mx-2
utilities.Use
h-24
to set an element to a fixed height(6rem).Use
md:h-32
to set an element to a fixed height(8rem) at only medium screen sizes.Control the margin on bottom side of an element to 0.5rem using the
mb-2
utilities.Control the text color of an element to gray-800 using the
text-gray-800
utilities.Control the text color of an element to 3xl at only medium screen sizes using the
md:text-3xl
utilities.Control the text color of an element to indigo-600 using the
text-indigo-600
utilities.Control the vertical margin of an element to 1rem using the
my-4
utilities.Control the horizontal padding of an element to 0.75rem using the
px-3
utilities.Control the text color of an element to indigo-400 using the
text-indigo-400
utilities.Control the margin on right side of an element to 0.25rem using the
mr-1
utilities.Control the text color of an element to 3xl using the
text-3xl
utilities.Control the text color of an element to green-500 using the
text-green-500
utilities.Control the text color of an element to xl using the
text-xl
utilities.Control the vertical padding of an element to 1rem using the
py-4
utilities.Control the text color of an element to center using the
text-center
utilities.Control the padding on top side of an element to 0.5rem using the
pt-2
utilities.Use the
right-0
utilities to set the right position of a positioned element to 0rem.Use
inline
utilities to put the element on its own line and fill its parent.Control the text color of an element to xs using the
text-xs
utilities.Adjust the left padding of an element to 1rem using the
pl-4
utilities classControl the padding on right side of an element to 2rem using the
pr-8
utilities.Use
h-14
to set an element to a fixed height(3.5rem).Control the padding on bottom side of an element to 0.25rem using the
pb-1
utilities.Use the
bottom-0
utilities to set the bottom position of a positioned element to 0rem.Control the margin on right side of an element to 0.5rem using the
mr-2
utilities.Control the horizontal padding of an element to 1.5rem using the
px-6
utilities.Control the background color of an element to indigo-600 using the
bg-indigo-600
utilities.Control the background color of an element to indigo-500 using the
hover:bg-indigo-500
utilities on hover.Control the text color of an element to white using the
text-white
utilities.
Conclusion
The above is a step-by-step tutorial on how to use Tailwind CSS to create a Product Detail Page With TailwindCSS 2.0 components, learn and follow along to implement your own components.