Rating Input
Оценка звёздами. Бесплатно, MIT · Формы и ввод › Флажки и ползунки
Установка
npx valyro-cli@latest add rating-input
npx shadcn@latest add https://valyro.xyz/r/rating-input.json
npm install valyro-ui
import 'valyro-ui/styles.css';
import { RatingInput } from 'valyro-ui';
Пропсы
| Prop | Type | Default | |
|---|---|---|---|
value | number | Controlled value; use with onValueChange. | |
defaultValue | number | 0 | Initial value when uncontrolled. |
onValueChange | (value: number) => void | Called with the new value when it changes. | |
max | number | 5 | Number of stars. |
allowHalf | boolean | false | Allow x.5 values (each star has a left and right half). |
readOnly | boolean | false | Display only; fractional values like 4.3 render as partial stars. |
disabled | boolean | false | Dims the stars and ignores input; the rating is not submitted with the form. |
size | 'sm' | 'md' | 'lg' | 'md' | Star size: 16 / 20 / 28px. |
invalid | boolean | false | Empty stars turn the danger color (aria-invalid). Also shown after a submit attempt while a required rating is missing. |
valueLabels | string[] | Text per whole star, e.g. ["Bad", …, "Excellent"]; shown next to the stars for the hovered or chosen value. | |
getValueLabel | (value: number, max: number) => string | defaultValueLabel | Accessible name of a value (each star, and the whole read-only rating). Default: "4 out of 5". |
name | string | Submits the rating with the surrounding form as a number ("3.5"; empty when unrated). Not for readOnly. | |
required | boolean | Blocks native form submission while nothing is rated. |
Похожие компоненты
- Checkbox — Флажки
- Checkbox Group — Флажки с общей подписью, подсказкой, ошибкой и обязательностью
- Radio Group — Выбор одного варианта
- Switch — Переключатель
- Slider — Ползунок
- Histogram Range — Диапазон цен с гистограммой, двумя ползунками и полями
- Text Input — Текстовые поля
- Textarea — Многострочный ввод
- Search Input — Поисковая строка
- Mentions Input — Текст с @упоминаниями и #тегами, асинхронные подсказки
- Tags Input — Ввод тегов
- Select — Выбор из списка
Назад: Histogram Range · Далее: Number Input · Весь раздел «Формы и ввод»