JSFiddle - React, Tailwind, and code Playground

by Alexander

HTML

<div class="rating">
    <span class="active">★</span>
    <span class="active">★</span>
    <span class="active">★</span>
    <span>★</span>
    <span>★</span>
</div>

CSS

body {
    margin: 20px;
}

.rating {
    cursor: pointer;
    unicode-bidi: bidi-override;
    text-align: center;
    color: #ccc;
}

.rating > span {
    display: inline-block;
    position: relative;
    width: 1.1em;
}

.rating span.active {
    color: transparent;
}

.rating span.active:before {
    content: "\2605";
    position: absolute;
    left: 0;
    color: green;
}