← Home

Tailwind... quick thought

@date=2024-12-15
@tags=programming, webdev

Look at a bunch of tailwind videos, and thought about how I code to see if the two would be compatiable.

Typically I make React components, and I give a class name to the top level of the react component. So, UserProfileCard would have the class .user-profile-card-component.

Then, I create a .scss file where that is the parent class and everything else is a child. I set all the styling for the component in there.

Anything that is a common thing, such as .card, I would put in main.scss, or site.scss or something like that.

Anything that defined colors, shadowing, sizing, etc, would go in the variables.scss file.

With all that, I like what I have. Generic chunks that get reused between components (like .card), some specifications, and a bit of component specific tailored styling.

Now looking at the little animated image demoing use of it on the tailwindcss.com website, I just can't see why I would want to use that for styling a component.

Pasted image 20241215105219.png

I would probably set something like:

.quote-card-component{
    .card{
        display:flex;
        .side-image.left{
           
        }
        .text-content{
            blockquote{
            }
            .person-label{
                .name{
                    &a{
                        
                    }
                }
                .title{
                }
            }
        }
    }
}

with all the relevant styling thrown in.

When I want to tweak this later, it is easy to find and change things. Also, plenty of this stuff could be generalized out of the quote-card-component, but it can also live in there until it needs to be reused elsewhere and then brought up to the global scope for a reused style.

For example, I would totally have card be put on the actual parent component element, and I wouldn't need to style the name's a tag here.

This isn't to rain too much on other's parade's. I think using tailwind is just as valid as putting inline css in style attributes on html elements. I do it once in a while as a one off, and having a library that makes that inline stuff more compressed is nice.

My main issues: