@molecule/app-rating-display-solid
Feature · rating-display · App (browser) · v1.1.2 · Apache-2.0
Read-only and interactive star rating display with half-star support
npm install @molecule/app-rating-display-solidHow it works
@molecule/app-rating-display-solid is a ready-made rating-display feature for the app (browser) side. It composes the core interfaces it needs, so it works with whichever providers your app has bonded.
import { createSignal } from 'solid-js'
import { RatingDisplay } from '@molecule/app-rating-display-solid'
export function ProductRating() {
const [rating, setRating] = createSignal(0)
const scrollToReviews = (): void => {
document.getElementById('reviews')?.scrollIntoView()
}
// First: read-only with review count. Second: interactive — user picks a rating.
return (
<>
<RatingDisplay value={4.5} reviewCount={128} onReviewsClick={scrollToReviews} />
<RatingDisplay value={rating()} size="lg" onChange={(v) => setRating(v)} />
</>
)
}Works with: @molecule/app-solid, @molecule/app-ui, @molecule/app-ui-solid
Reference
Solid star-rating display.
Exports RatingDisplay — fractional star rendering (inline SVG), optional
review count tail, optional interactive mode via onChange. It is the
Solid counterpart of @molecule/app-rating-display-react: same props
(React names), same DOM for the same input.
Auto-generated, AI-first package reference for the molecule.dev ecosystem. It is written to be read by coding agents as much as by people, and is generated from this package's source — edit
src/index.tsJSDoc, not this file.
Quick Start
import { createSignal } from 'solid-js'
import { RatingDisplay } from '@molecule/app-rating-display-solid'
export function ProductRating() {
const [rating, setRating] = createSignal(0)
const scrollToReviews = (): void => {
document.getElementById('reviews')?.scrollIntoView()
}
// First: read-only with review count. Second: interactive — user picks a rating.
return (
<>
<RatingDisplay value={4.5} reviewCount={128} onReviewsClick={scrollToReviews} />
<RatingDisplay value={rating()} size="lg" onChange={(v) => setRating(v)} />
</>
)
}
Type
feature
Installation
npm install @molecule/app-rating-display-solid @molecule/app-solid @molecule/app-ui @molecule/app-ui-solid solid-js
API
Interfaces
RatingDisplayProps
Props for RatingDisplay.
interface RatingDisplayProps {
/** Rating value (0–max). Fractional supported. */
value: number
/** Maximum rating. Defaults to 5. */
max?: number
/** Optional review count shown after the stars. */
reviewCount?: number
/**
* Called when the review-count is clicked (renders it as a button). React
* passes the click event, so this receives it too.
*/
onReviewsClick?: (event?: MouseEvent) => void
/** Size preset. */
size?: 'sm' | 'md' | 'lg'
/** Interactive mode — star clicks call `onChange(starIndex + 1)`. */
onChange?: (value: number) => void
/** Accessible label override; defaults to the translated `Rating: {value} of {max}`. */
ariaLabel?: string
/** Extra classes. */
className?: string
}
Functions
RatingDisplay(props)
Star-rating display supporting fractional values and an optional
review-count tail. When onChange is provided each star becomes an
interactive button.
The stars sit in an inner span that carries the rating label — role="img"
when read-only, role="group" (holding the rate buttons) in interactive
mode — and the root is a plain flex span, exactly as React's does.
Uses inline SVG stars so the component works without icon-font fallback.
Same props (React names) and same DOM as
@molecule/app-rating-display-react's RatingDisplay.
function RatingDisplay(props: RatingDisplayProps): JSX.Element
props— Component props (seeRatingDisplayProps).
Returns: The rendered rating display.
Injection Notes
Requirements
Peer dependencies:
@molecule/app-solid^3.5.0 || ^4.0.0@molecule/app-ui^1.0.1@molecule/app-ui-solid^1.1.0solid-js^1.8.0
Runtime Dependencies
@molecule/app-solid@molecule/app-ui@molecule/app-ui-solidsolid-js
Stars are inline SVG filled with currentColor — set a text color on the
wrapper (e.g. a warning/amber token) to tint them; unfilled portions render
at 25% opacity of the same color. Accessible labels are translated through
useTranslation(), matching the React package and following a locale switch:
the container label (ratingDisplay.aria.rating, overridable via ariaLabel)
and the per-star "Rate N of M" button labels in interactive mode
(ratingDisplay.aria.rate). Requires a wired ClassMap bond.
Translations
Translation strings are provided by @molecule/app-locales-rating-display.