There’s one final point I’d like to stress before we move on — and I cannot stress this enough.
Whenever you feel the urge to create a component, do it.
Using Tailwind doesn’t mean you can’t create CSS component files. For example, just look at the number of components I created for two of my websites!
CSS Files > Framework Component Files
One of Tailwind’s official strategies for reusing styles is to extract them into component files. I find that advice to be a joke — because you can extract styles into CSS and make them even more reusable.
Imagine building a button component… you tell me which is more convenient:
Creating and using a button component
<-- Button.astro file --><button class="p-4 bg-blue-500"> <slot /></button>---import Button from '../components/Button.astro'---
<-- Using the button component --><Button> ... </Button>Or simply just using CSS…
/* CSS file */.button { padding: 1rem; background: var(--color-blue-500);}<a class="button"> ... </a> <button class="button">...</button>I shall not say any more for now or I might not stop ranting… but we’ll cover this in more detail when we close up in the last chapter.
And now, without further ado, let’s dive into each of the categories to discover how to create utilities that facilitate your styling process!
Welcome! Unfortunately, you don’t have access to this lesson. To get access, please purchase the course or enroll in Magical Dev School.
Unlock this lesson