CODING
Build an Accordion Menu with React & Tailwind CSS
Video | Code Commerce
I've been very slowly trying to learn React which is a front-end JavaScript library for building user interfaces. Because I rarely have time to work on a React project in full I watch short tutorials to pick up concepts.
In this tutorial they are also using Tailwind CSS which I think is really cool and have been learning. In simple terms, Tailwind CSS allows you to use unique class names for quickly styling elements within your HTML. You don't need to write your own CSS, saving you tons of time.
For example, let's say I want to style a div container to have 20px of padding on all sides.
A standard method for doing this looks like:
<div class="my-style">Hello
.my-style {
padding: 20px;
}
With Tailwind CSS there's no need to touch your stylesheet. Everything is preset with class names. So it would look like:
<div class="p-20">Hello
What if you want to quickly add rounded corners?
<div class="p-20 rounded">Hello
And you want the text to be the color blue? No problem.
<div class="p-20 rounded text-blue">Hello
I think Tailwind CSS is pretty awesome and a great time saver. Now, you can imagine how complicated the HTML can read though with all these classes in the code. So there's pros and cons, but for quick prototyping this framework is great.