stars() table()

Show a rating as a row of star icons.

table()->stars($name, $desc = '', $extra = [])

Options

OptionMeaning
starsNumber of stars; default 5.
maxValue of a full row; default 5 (['stars' => 5, 'max' => 100] for a percent).
color_ok, color_koColours of lit and dim stars; default yellow and none.
class, class_ok, class_koIcon class (CLASS_ICON_STAR) and the classes of lit and dim stars.

Example

Name Rating Score
Desk lamp
Office chair

Code

$rows = [
    1 => ['id' => 1, 'name' => 'Desk lamp', 'rating' => 4, 'score' => 35],
    2 => ['id' => 2, 'name' => 'Office chair', 'rating' => 2, 'score' => 90],
];
return table($rows, ['no_pages' => 1])
    ->text('name')
    ->stars('rating')
    ->stars('score', ['stars' => 5, 'max' => 100, 'color_ko' => '#ccc']);

See also: form/stars, demo:table/form