-
Notifications
You must be signed in to change notification settings - Fork 5.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat: ✨ new Rating Component #2951
base: main
Are you sure you want to change the base?
Conversation
@flixlix is attempting to deploy a commit to the shadcn-pro Team on Vercel. A member of the Team first needs to authorize it. |
The latest updates on your projects. Learn more about Vercel for Git ↗︎
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
ff4ab58
to
117ee84
Compare
LGTM! 🚀 |
Hey, Is it possible to rate, or display decimal values such as 3.5 , 4.5? |
✨ New Rating Component
This implementation is based on
@radix-ui/react-radio-group
, which makes it more accessible, since it is also navigable with a keyboard.Screen.Recording.2024-03-08.at.14.36.59.mov
Custom icon
A custom icon can be passed as an
Icon
prop. Depending on the style, you should pass a Lucide Icon or a Radix Icon. The Rating components handles all states.count
A custom amount of ratings can be passed to adjust the granularity of the rating using the
ratingSteps
prop.custom label
By default the label will be
(${currentValue}/${totalSteps})
. This can be overridden by simply passing acustomLabel
prop as a string.disabled
To show the user the rating component is disabled, the opacity of the icons is lowered.
readonly
In contrary to the disabled state, the readonly is supposed to be used in cases where the component merely displays the current rating and never expects any input to be entered.
In this case the component looks the same but cursor events as well as keyboard events are turned off.