Inputs

Ten Point Scale

A ten-point scale of numbered cells: at ten notches stars have to be recounted by eye, while a digit names the score straight away.

  • rating
  • scale
  • survey
  • keyboard

Preview

1440pxHost theme

Use it with AI

  1. 1. Copy the link.
  2. 2. Write to your agent in your own words and drop the link into the sentence.
  3. 3. The agent opens the link and installs the component from the registry.

put this in the header: https://vibeui.ru/c/rating-003?lang=en

Rate the service8 / 10

1 — совсем плохохорошо

Show the full instructions

What the link says, spelled out. Use it when your agent cannot open links — paste this text instead.

# Install and place "rating-003" (Ten Point Scale) from VibeUI

## 1. Install first — do not skip, do not recreate
Run this exact command before writing any code:
npx shadcn@latest add https://vibeui.ru/r/rating-003.json

Registry item: https://vibeui.ru/r/rating-003.json
Installs to: components/vibeui/rating-003.tsx (the exact path follows this project's components.json aliases).
npm dependencies: none.
Registry dependencies: none.

Install it from the registry. Do not recreate it from the description,
do not substitute a similar component from another library, and do not
rewrite it to match the project's existing style.

## 2. What it is
A ten-point scale of numbered cells: at ten notches stars have to be recounted by eye, while a digit names the score straight away.

A one-to-ten scale of numbered cells with cumulative fill; arrow keys move the choice inside the group. Zero dependencies, one file.

## 3. How to use it
import { Rating003 } from "@/components/vibeui/rating-003"

<Rating003 label="Rate the service" max={10} defaultValue={8} />

Read the installed file for the full prop list.

## 4. Where to place it
This is a small inline component. Put it exactly where the user asked,
inside the existing markup. Do not create a new page, section or
wrapper for it. If a similar control already sits in that spot,
replace it instead of adding a second one.

Placement: ___
(The user fills this line in. If it is still blank, ask where to put it
instead of guessing.)

## 5. Keep exactly as installed
- the local --vibeui-rating-003-* palette — do not swap it for your theme tokens
- its own light surface: the scale gets shown over any background
- digits instead of glyphs: at ten notches stars have to be recounted by eye
- the roving tabindex: without it ten buttons join the tab order and the next form field is ten Tabs away
- the radiogroup and radio roles: role-less buttons read as ten unrelated commands to a screen reader
- the cumulative fill: a bar length reads faster than the position of a single mark
- the aria-label with the score on every cell: a lone digit means nothing out of context

## 6. You may change
- label — the question above the scale
- max — the scale length, seven points works too
- defaultValue — the pre-selected score
- hints — the words under the scale for each score
- the accent through the accent prop

## 7. Rules
- The hints length has to match max, otherwise the outer scores caption nothing.
- The scale starts at one: NPS needs a different one, starting at zero.
- The component is self-contained: add your own onChange to lift the score up.
- Do not lift the CSS variables into globals.css: the component has to stay a single file.

## 8. Verify
- it renders with no console errors;
- it looks like the preview on the VibeUI page you copied this from;
- if it does not, you changed something listed in section 5 — put it back.

For developers

npx shadcn@latest add https://vibeui.ru/r/rating-003.json
https://vibeui.ru/r/rating-003.json

Компонент самодостаточен: один файл, ноль зависимостей, палитра в локальных переменных --vibeui-rating-003-*. Клиентский: оценка в состоянии, есть обработка стрелок. Группа собрана на ролях radiogroup и radio с ручным roving tabindex: фокус входит в группу один раз, а стрелки двигают выбор внутри — десять кнопок в табуляции означали бы десять лишних нажатий Tab до следующего поля. Клетки до выбранной заливаются приглушённым акцентом через color-mix, поэтому оценка читается и как число, и как длина.

Component source

The same file your agent installs. Here in case you would rather copy it by hand.

"use client"

import { useId, useState } from "react"
import type {
  ComponentPropsWithoutRef,
  CSSProperties,
  KeyboardEvent,
} from "react"

export type Rating003Props = Omit<
  ComponentPropsWithoutRef<"div">,
  "children" | "defaultValue" | "onChange"
> & {
  label?: string
  max?: number
  defaultValue?: number
  hints?: string[]
  accent?: string
}

// Идея компонента: десятибалльная шкала как ряд пронумерованных клеток. Звёзды
// на десяти делениях перестают считываться — приходится пересчитывать значки
// глазами, а цифра называет оценку сразу. Клетки до выбранной закрашиваются,
// поэтому оценка читается и как число, и как длина. Группа собрана на ролях
// radiogroup/radio с ручным roving tabindex: десять кнопок в табуляции — это
// десять лишних нажатий Tab, поэтому фокус в группу входит один раз, а стрелки
// двигают выбор внутри.
const STYLES = `
:where([data-vibeui-block="rating-003"]){
--vibeui-rating-003-surface:oklch(1 0 0);
--vibeui-rating-003-shell:oklch(0.9 0.006 265);
--vibeui-rating-003-fg:oklch(0.23 0.014 265);
--vibeui-rating-003-muted:oklch(0.55 0.014 265);
--vibeui-rating-003-border:oklch(0.9 0.006 265);
--vibeui-rating-003-empty:oklch(0.97 0.003 265);
--vibeui-rating-003-accent:oklch(0.55 0.17 265);
--vibeui-rating-003-on:oklch(1 0 0);
--vibeui-rating-003-font:ui-sans-serif,system-ui,-apple-system,"Segoe UI",Roboto,"Helvetica Neue",Arial,sans-serif;
}
/* Своя светлая подложка: шкалу показывают поверх любого фона. */
[data-vibeui-block="rating-003"]{
display:flex;flex-direction:column;gap:0.5rem;
width:100%;max-width:22rem;box-sizing:border-box;padding:0.875rem;
background:var(--vibeui-rating-003-surface);
border:1px solid var(--vibeui-rating-003-shell);border-radius:0.875rem;
font-family:var(--vibeui-rating-003-font);color:var(--vibeui-rating-003-fg);
}
[data-vibeui-block="rating-003"] [data-part="head"]{
display:flex;align-items:baseline;justify-content:space-between;gap:0.75rem;margin:0;
}
[data-vibeui-block="rating-003"] [data-part="title"]{font-size:0.8125rem;font-weight:650}
[data-vibeui-block="rating-003"] [data-part="score"]{
font-size:0.8125rem;font-weight:700;color:var(--vibeui-rating-003-accent);
font-variant-numeric:tabular-nums;
}
[data-vibeui-block="rating-003"] [data-part="scale"]{display:flex;gap:0.1875rem}
[data-vibeui-block="rating-003"] button{
appearance:none;cursor:pointer;flex:1 1 0;min-width:0;
height:2.25rem;padding:0;
border:1px solid var(--vibeui-rating-003-border);border-radius:0.375rem;
background:var(--vibeui-rating-003-empty);color:var(--vibeui-rating-003-muted);
font:inherit;font-size:0.75rem;font-weight:700;font-variant-numeric:tabular-nums;
transition:background-color .12s ease,color .12s ease,border-color .12s ease;
}
/* Клетки до выбранной закрашены: оценка читается и числом, и длиной. */
[data-vibeui-block="rating-003"] button[data-filled="true"]{
background:color-mix(in oklch,var(--vibeui-rating-003-accent) 22%,white);
border-color:transparent;color:var(--vibeui-rating-003-fg);
}
[data-vibeui-block="rating-003"] button[aria-checked="true"]{
background:var(--vibeui-rating-003-accent);border-color:transparent;
color:var(--vibeui-rating-003-on);
}
[data-vibeui-block="rating-003"] button:focus-visible{outline:2px solid var(--vibeui-rating-003-accent);outline-offset:2px}
[data-vibeui-block="rating-003"] [data-part="foot"]{
display:flex;align-items:center;justify-content:space-between;gap:0.75rem;margin:0;
font-size:0.6875rem;color:var(--vibeui-rating-003-muted);
}
[data-vibeui-block="rating-003"] [data-part="hint"]{
font-size:0.75rem;font-weight:650;color:var(--vibeui-rating-003-fg);
}
@media (prefers-reduced-motion:reduce){[data-vibeui-block="rating-003"] *{animation:none!important;transition:none!important}}
`

const DEFAULT_HINTS = [
  "никогда",
  "очень плохо",
  "плохо",
  "слабо",
  "терпимо",
  "средне",
  "неплохо",
  "хорошо",
  "очень хорошо",
  "отлично",
]

/**
 * Десятибалльная шкала пронумерованными клетками с накопительной заливкой.
 * Один файл, ноль зависимостей, собственная палитра.
 */
export function Rating003({
  label = "Оцените сервис",
  max = 10,
  defaultValue = 8,
  hints = DEFAULT_HINTS,
  accent,
  className,
  style,
  ...props
}: Rating003Props) {
  const id = useId()
  const [value, setValue] = useState(defaultValue)
  const points = Array.from({ length: max }, (_, index) => index + 1)

  // Стрелки двигают выбор внутри группы: десять кнопок в табуляции — это
  // десять лишних нажатий Tab до следующего поля формы.
  const onKeyDown = (event: KeyboardEvent<HTMLDivElement>) => {
    const delta =
      event.key === "ArrowRight" || event.key === "ArrowUp"
        ? 1
        : event.key === "ArrowLeft" || event.key === "ArrowDown"
          ? -1
          : 0
    if (delta === 0) return
    event.preventDefault()
    setValue(Math.min(max, Math.max(1, value + delta)))
  }

  const palette = {
    ...(accent ? { "--vibeui-rating-003-accent": accent } : null),
    ...style,
  } as CSSProperties

  return (
    <>
      <style href="vibeui-rating-003" precedence="medium">
        {STYLES}
      </style>
      <div
        {...props}
        data-vibeui-block="rating-003"
        className={className}
        style={palette}
      >
        <p data-part="head">
          <span data-part="title" id={`${id}-label`}>
            {label}
          </span>
          <span data-part="score" aria-live="polite">
            {value} / {max}
          </span>
        </p>
        <div
          data-part="scale"
          role="radiogroup"
          aria-labelledby={`${id}-label`}
          onKeyDown={onKeyDown}
        >
          {points.map((point) => (
            <button
              key={point}
              type="button"
              role="radio"
              aria-checked={value === point}
              aria-label={`${point} из ${max}`}
              tabIndex={value === point ? 0 : -1}
              data-filled={point < value}
              onClick={() => setValue(point)}
            >
              {point}
            </button>
          ))}
        </div>
        <p data-part="foot">
          <span>1 — совсем плохо</span>
          <span data-part="hint">{hints[value - 1]}</span>
        </p>
      </div>
    </>
  )
}