- Published on
The 5 Really Obvious Ways To Create A Tags With Tailwind CSS Better That You Ever Did
- What is Tailwind CSS?
- The description of Tags ui component
- Why use Tailwind CSS to create a Tags ui component?
- The preview of Tags ui component
- The source code of Tags ui component
- How to create a Tags with Tailwind CSS?
- Install tailwind css of verion 1.2.0
- All the unility class needed to create a Tags component
- 16 steps to create a Tags 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 Tags ui component
Why use Tailwind CSS to create a Tags ui component?
- It can make the building process of Tags ui component faster and more easily.
- Enables building complex responsive layouts and components freely.
- Minimum lines of CSS code in Tags component file.
The preview of Tags ui component
Free download of the Tags's source code
The source code of Tags ui component
<div>
<div
class="text-xs inline-flex items-center font-bold leading-sm uppercase px-3 py-1 bg-blue-200 text-blue-700 rounded-full"
>
<svg
xmlns="http://www.w3.org/2000/svg"
width="16"
height="16"
viewBox="0 0 24 24"
fill="none"
stroke="currentColor"
stroke-width="2"
stroke-linecap="round"
stroke-linejoin="round"
class="feather feather-bell-off mr-2"
>
<path d="M13.73 21a2 2 0 0 1-3.46 0"></path>
<path d="M18.63 13A17.89 17.89 0 0 1 18 8"></path>
<path d="M6.26 6.26A5.86 5.86 0 0 0 6 8c0 7-3 9-3 9h14"></path>
<path d="M18 8a6 6 0 0 0-9.33-5"></path>
<line x1="1" y1="1" x2="23" y2="23"></line>
</svg>
Tag
</div>
<div
class="ml-4 text-xs inline-flex items-center font-bold leading-sm uppercase px-3 py-1 bg-green-200 text-green-700 rounded-full"
>
<svg
xmlns="http://www.w3.org/2000/svg"
width="16"
height="16"
viewBox="0 0 24 24"
fill="none"
stroke="currentColor"
stroke-width="2"
stroke-linecap="round"
stroke-linejoin="round"
class="feather feather-arrow-right mr-2"
>
<line x1="5" y1="12" x2="19" y2="12"></line>
<polyline points="12 5 19 12 12 19"></polyline>
</svg>
Tag
</div>
<div
class="ml-4 text-xs inline-flex items-center font-bold leading-sm uppercase px-3 py-1 bg-orange-200 text-orange-700 rounded-full"
>
<svg
xmlns="http://www.w3.org/2000/svg"
width="16"
height="16"
viewBox="0 0 24 24"
fill="none"
stroke="currentColor"
stroke-width="2"
stroke-linecap="round"
stroke-linejoin="round"
class="feather feather-activity mr-2"
>
<polyline points="22 12 18 12 15 21 9 3 6 12 2 12"></polyline>
</svg>
Tag
</div>
<div
class="ml-4 text-xs inline-flex items-center font-bold leading-sm uppercase px-3 py-1 bg-red-200 text-red-700 rounded-full"
>
<svg
xmlns="http://www.w3.org/2000/svg"
width="16"
height="16"
viewBox="0 0 24 24"
fill="none"
stroke="currentColor"
stroke-width="2"
stroke-linecap="round"
stroke-linejoin="round"
class="feather feather-archive mr-2"
>
<polyline points="21 8 21 21 3 21 3 8"></polyline>
<rect x="1" y="3" width="22" height="5"></rect>
<line x1="10" y1="12" x2="14" y2="12"></line>
</svg>
Tag
</div>
<div
class="ml-4 text-xs inline-flex items-center font-bold leading-sm uppercase px-3 py-1 rounded-full bg-white text-gray-700 border"
>
<svg
xmlns="http://www.w3.org/2000/svg"
width="16"
height="16"
viewBox="0 0 24 24"
fill="none"
stroke="currentColor"
stroke-width="2"
stroke-linecap="round"
stroke-linejoin="round"
class="feather feather-hard-drive mr-2"
>
<line x1="22" y1="12" x2="2" y2="12"></line>
<path
d="M5.45 5.11L2 12v6a2 2 0 0 0 2 2h16a2 2 0 0 0 2-2v-6l-3.45-6.89A2 2 0 0 0 16.76 4H7.24a2 2 0 0 0-1.79 1.11z"
></path>
<line x1="6" y1="16" x2="6.01" y2="16"></line>
<line x1="10" y1="16" x2="10.01" y2="16"></line>
</svg>
Tag
</div>
</div>
How to create a Tags with Tailwind CSS?
Install tailwind css of verion 1.2.0
Use the link
html tag to import the stylesheet of Tailwind CSS of the version 1.2.0
<link href=https://unpkg.com/[email protected]/dist/tailwind.min.css rel="stylesheet">
All the unility class needed to create a Tags component
text-xs
inline-flex
px-3
py-1
bg-blue-200
text-blue-700
mr-2
ml-4
bg-green-200
text-green-700
bg-orange-200
text-orange-700
bg-red-200
text-red-700
bg-white
text-gray-700
16 steps to create a Tags component with Tailwind CSS
Control the text color of an element to xs using the
text-xs
utilities.Use
inline-flex
to create an inline flex container that flows with text.Control the horizontal padding of an element to 0.75rem using the
px-3
utilities.Control the vertical padding of an element to 0.25rem using the
py-1
utilities.Control the background color of an element to blue-200 using the
bg-blue-200
utilities.Control the text color of an element to blue-700 using the
text-blue-700
utilities.Control the margin on right side of an element to 0.5rem using the
mr-2
utilities.Control the margin on left side of an element to 1rem using the
ml-4
utilities.Control the background color of an element to green-200 using the
bg-green-200
utilities.Control the text color of an element to green-700 using the
text-green-700
utilities.Control the background color of an element to orange-200 using the
bg-orange-200
utilities.Control the text color of an element to orange-700 using the
text-orange-700
utilities.Control the background color of an element to red-200 using the
bg-red-200
utilities.Control the text color of an element to red-700 using the
text-red-700
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.
Conclusion
The above is a step-by-step tutorial on how to use Tailwind CSS to create a Tags components, learn and follow along to implement your own components.