I used the following CSS:
function make_star_bar( $atts ) {
$value = shortcode_atts( array(
‘stars’ =>5,
‘color’ => ‘#f00’
),$atts);
$percentage = 100 * $value[‘stars’] / 5;
$html = ‘★★★★★
.star-bar {
background: linear-gradient(90deg, ‘. $value[‘color’] . ‘ ‘ . $percentage .’%, rgba(0,0,0,0) ‘. $percentage.’%);
color: rgba(0,0,0,.2);
background-clip: text;
-webkit-background-clip: text;
color: rgba(0,0,0,.2);
}
‘;
return $html;
}
add_shortcode(‘star_bar’, ‘make_star_bar’);