Svelte Rating - Bitblue

Star ratings with partial fills, custom totals, and optional text

Rating renders a read-style star row with optional partial fill, custom icon, and trailing text.

Setup

<script lang="ts">
	import { Rating } from '.';
</script>

Default rating

Defaults to rating={4} of total={5} at size={24}.

<Rating />

With text snippet

4.5 out of 5

<script lang="ts">
	import { Rating } from '.';
</script>

<Rating rating={4.5}>
	{#snippet text()}
		<p class="ms-2 text-sm font-medium text-gray-500">4.5 out of 5</p>
	{/snippet}
</Rating>

Count mode

count shows a single filled star plus the numeric value; put review copy in children.

3.2

(12 reviews)

<script lang="ts">
	import { Rating } from '.';
</script>

<Rating count rating={3.2}>
	<p class="ms-2 text-sm">(12 reviews)</p>
</Rating>

Custom size / total

<Rating size={18} rating={3} />
<Rating size={32} total={10} rating={7.5} />

Partial fills

Fractional rating values fill the next star by percentage.

<Rating rating={3.25} />
<Rating rating={3.5} />
<Rating rating={3.75} />

Custom icon

Pass any component that implements RatingIconProps (fillPercent, size, groupId, …). Default icon is Star.

<script lang="ts">
	import { Rating } from '.';
	import CustomStar from './CustomStar.svelte';
</script>

<Rating rating={4} icon={CustomStar} />

Props

PropTypeDefaultDescription
ratingnumber4Filled value (supports fractions)
totalnumber5Number of icons
sizenumber24Icon size in px
countbooleanfalseCompact single-star + value layout
textSnippet—Trailing text when not in count mode
childrenSnippet—Extra content (used with count)
iconComponent<RatingIconProps>StarCustom star icon component
class / classestheme slots—base / value overrides
...restHTMLAttributes<HTMLDivElement>—Root attributes

RatingIconProps (custom icons)

PropTypeDescription
fillPercentnumber0–100 fill
fillColor / strokeColorstringColors
sizenumberPixel size
ariaLabelstringAccessible label
iconIndex / groupIdnumber / stringGradient id helpers
rolestringSVG role

© 2026 Bitblue is a registered trademark. All Rights Reserved.