ValyroUI English version

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';

Пропсы

PropTypeDefault
valuenumberControlled value; use with onValueChange.
defaultValuenumber0Initial value when uncontrolled.
onValueChange(value: number) => voidCalled with the new value when it changes.
maxnumber5Number of stars.
allowHalfbooleanfalseAllow x.5 values (each star has a left and right half).
readOnlybooleanfalseDisplay only; fractional values like 4.3 render as partial stars.
disabledbooleanfalseDims the stars and ignores input; the rating is not submitted with the form.
size'sm' | 'md' | 'lg''md'Star size: 16 / 20 / 28px.
invalidbooleanfalseEmpty stars turn the danger color (aria-invalid). Also shown after a submit attempt while a required rating is missing.
valueLabelsstring[]Text per whole star, e.g. ["Bad", …, "Excellent"]; shown next to the stars for the hovered or chosen value.
getValueLabel(value: number, max: number) => stringdefaultValueLabelAccessible name of a value (each star, and the whole read-only rating). Default: "4 out of 5".
namestringSubmits the rating with the surrounding form as a number ("3.5"; empty when unrated). Not for readOnly.
requiredbooleanBlocks 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 · Весь раздел «Формы и ввод»