Forms

Rating.

Give every star its moment.

Live preview

Live preview
4 out of 5 stars
tsx
import { Rating } from "luminescent";
import "luminescent/style.css";


export function Example() {
  return <Rating label="Rate your experience" defaultValue={4} name="rating" />;
}

Installation

bash
npm install luminescent

Import luminescent/style.css once at your application root. The example above uses the same package implementation as Storybook.

Variants and states

Use the preview controls to explore the supported variants, sizes, disabled/loading states and reduced motion. Controls appear only where the component exposes the corresponding prop. Theme and glow apply to every component.

Controlled and uncontrolled state

State contract: value / defaultValue / onChange (number). Omit the controlled prop to let the component own its initial state; supply a value and callback when your application owns it. Native uncontrolled fields and state-backed form controls participate in form reset. Controlled state must be reset by the application.

tsx
import { useState } from "react";
import { Rating } from "luminescent";


export function ControlledExample() {
  const [value, setValue] = useState(4);
  return <Rating label="Quality" value={value} onChange={setValue} />;
}

API reference

Generated from the source TypeScript interfaces. Native attributes, className, style, aria-* and data-* also pass through to the documented element. Import RatingProps from the package for the full inherited contract.

PropTypeDetails
valuenumberOptional unless marked required.
defaultValuenumberOptional unless marked required.
onChange(value: number) => voidOptional unless marked required.
maxnumberOptional unless marked required.
namestringOptional unless marked required.
labelstringOptional unless marked required.
disabledbooleanOptional unless marked required.
readOnlybooleanOptional unless marked required.
size'sm' | 'md' | 'lg'Optional unless marked required.
glowColorGlowColorOptional unless marked required.

Accessibility and keyboard

Native radio keyboard interaction. readOnly renders a single image summary. Integer values are clamped; max is bounded to 1–100. This component does not support fractional ratings.

Keep labels meaningful and test application-level contrast, focus order and screen-reader output. See the accessibility guide for composition requirements.

Theme customization

tsx
import { LuminescentProvider, Rating } from "luminescent";
import "luminescent/style.css";


export function Example() {
  return (
    <LuminescentProvider theme="light" accent="violet" glow="subtle">
      <Rating label="Rate your experience" defaultValue={4} name="rating" />
    </LuminescentProvider>
  );
}

Switch between light and dark in the preview, or open the playground for a larger workspace. Custom CSS variables can override spacing, color, typography and effects.

Related components