DEV Community

Discussion on: CSS SVG star rating ⭐️

Collapse
 
dailydevtips1 profile image
Chris Bongers

Yeah, attribute nth-child would be a nice one, hey.

Your right could actually have swapped for x on the use. You know how you get into this code and debugging, and then it sticks, haha.

As for your one star, that's not completely true. Since you want dynamic colors based on the same, it's almost impossible to overwrite the color then or do the half stars.

I'll put this on my list to refactor to use the x instead of the nth-child.
Also, you could have defs and created fixed defs for each option so you can just use 1 single-use, but that's if you need all of them.

Collapse
 
darkwiiplayer profile image
𒎏Wii 🏳️‍⚧️

Half-stars can easily be done using a linear gradient with two stops at 50% (you can even move it around at random). As for the dynamic colours, I don't really get what you mean by that. Unless you want to change the actual shape of the star, almost everything can be done using CSS.