HextaUI

Rating (UI SDK): Deselectable

With deselectable, pressing the checked star again clears the score.

import { Rating, RatingItem } from "@/components/ui/ui-sdk-rating"

function UiSdkRatingDeselectable() {
  return (
    <Rating aria-label="Rating" deselectable defaultValue={2}>
      <RatingItem />
    </Rating>
  )
}

export { UiSdkRatingDeselectable }

This adds the example as components/examples/ui-sdk-rating/deselectable.tsx, together with the Rating component and the HextaUI theme tokens it needs.

pnpm dlx shadcn@latest add https://hextaui.com/r/ui-sdk-rating-deselectable.json

To add only the component, follow the Rating installation.

Props in this example

The Rating props this example sets, from the API reference.

PropTypeDefault
defaultValue
number | null–
deselectable
booleanfalse

Every prop is in the Rating API reference.

See them all, with keyboard support and accessibility notes, on the Rating page.