# Rating input

Collect a bounded rating through native radios with exact form values.

Access: pro. Category: Forms. Kind: primitive.

## When to use

- Use it when a product interface needs collect a bounded rating through native radios with exact form values.
- Choose it when the host application can supply the required state and keep business logic outside the presentation component.

## Alternatives

- Choose form-field instead when a labeled email field with validation and help text is the actual interface need, rather than rating input.

## Setup for agents

Use React 19 and TypeScript. Initialize shadcn for your framework, then merge this exact entry into components.json:

```json
{
  "registries": {
    "@tidal-pro": {
      "url": "https://tidalui.com/r/pro/{name}.json",
      "headers": {
        "Authorization": "Bearer ${TIDALUI_TOKEN}"
      }
    }
  }
}
```

The namespace must be named **@tidal-pro** because transitive Pro dependencies use that namespace. Obtain an agent key from your active Pro account at https://tidalui.com/account. Keep TIDALUI_TOKEN in your local environment, never in components.json, client code, Git or logs.

```sh
export TIDALUI_TOKEN='your-private-agent-key'
npx shadcn@latest add @tidal-pro/waitlist-form
npx shadcn@latest add https://tidalui.com/r/tidal-button.json
```

Free command: `npx shadcn@latest add https://tidalui.com/r/<name>.json`.
Pro command: `npx shadcn@latest add @tidal-pro/<name>`.

Import the base stylesheet and every stylesheet listed on the installed item's metadata. For example:

```tsx
import "./components/ui/tidal.css";
import "./components/ui/hero-section.css";
// Place installed components inside this wrapper:
<div className="tidal-scope" data-theme="dark">...</div>
```

Omit data-theme for the default light theme. Put the attribute on the same tidal-scope element for dark mode. Every component installs the shared free tidal-base dependency. After upgrading, run `npx shadcn@latest add https://tidalui.com/r/tidal-base.json --overwrite` to receive current tokens. Review local modifications before overwriting.

Vite: Use React + TypeScript. Map @/* to ./src/* in paths and Vite resolve.alias. Import tidal.css and each component stylesheet in your application entry.

Next.js 15 App Router: Next.js App Router: import tidal.css and component CSS in app/layout.tsx. Interactive examples belong in a client component with "use client". Map @/* to ./* or ./src/* to match your project.

TypeScript 6: use paths without baseUrl:

```json
{
  "compilerOptions": {
    "paths": {
      "@/*": [
        "./src/*"
      ]
    }
  }
}
```

Pro registry requests are server/CLI-only. Use the same-origin account interface in a browser; cross-origin Authorization preflights are intentionally unsupported.


## Install Rating input

```sh
npx shadcn@latest add @tidal-pro/rating-input
```

Stylesheets: `components/ui/tidal.css`, `components/ui/rating-input.css`.

## Minimal example

```tsx
import"./components/ui/tidal.css";
import"./components/ui/rating-input.css";
import{TidalRatingInput}from"./components/ui/rating-input";
export default()=><div className="tidal-scope"><TidalRatingInput label={"Demo"} name={"Demo"} onValueChange={() => {}} value={1}/></div>;
```

## Structured props

- `TidalRatingInput.label: ReactNode`: Required label value accepted by this exported component.
- `TidalRatingInput.name: string`: Required name value accepted by this exported component.
- `TidalRatingInput.onValueChange: (value: number | null, event: ChangeEvent<HTMLInputElement> | MouseEvent<HTMLButtonElement>) => void`: Callback invoked when the value change interaction is proposed.
- `TidalRatingInput.value: number | null`: Required value value accepted by this exported component.
- `TidalRatingInput.clearButtonProps?: Omit<Omit<DetailedHTMLProps<ButtonHTMLAttributes<HTMLButtonElement>, HTMLButtonElement>, "ref">, "type" | "children" | "dangerouslySetInnerHTML"> | undefined`: Optional clear button props value accepted by this exported component.
- `TidalRatingInput.clearButtonRef?: Ref<HTMLButtonElement> | undefined`: Optional clear button ref value accepted by this exported component.
- `TidalRatingInput.clearLabel?: string | undefined` (default "Clear rating"): Optional clear label value accepted by this exported component.
- `TidalRatingInput.description?: ReactNode`: Optional description value accepted by this exported component.
- `TidalRatingInput.error?: ReactNode`: Optional error value accepted by this exported component.
- `TidalRatingInput.form?: string | undefined`: Optional form value accepted by this exported component.
- `TidalRatingInput.invalidLabel?: ReactNode` (default "Rating options or the selected value are invalid."): Optional invalid label value accepted by this exported component.
- `TidalRatingInput.options?: ReadonlyArray<TidalRatingOption> | undefined` (default defaults): Optional options value accepted by this exported component.
- `TidalRatingInput.readOnly?: boolean | undefined` (default false): Optional read only value accepted by this exported component.
- `TidalRatingInput.required?: boolean | undefined` (default false): Optional required value accepted by this exported component.
- `TidalRatingInput.showClear?: boolean | undefined` (default true): Optional show clear value accepted by this exported component.
- `TidalRatingInput.unratedLabel?: string | undefined` (default "Not rated"): Optional unrated label value accepted by this exported component.
- `TidalRatingInput.valueLabel?: ((value: number) => ReactNode) | undefined` (default (v) => `${v} selected`): Optional value label value accepted by this exported component.

## Complete usage example

[Source](https://tidalui.com/examples/rating-input.tsx) | [Manifest](https://tidalui.com/examples/rating-input.json). Install the listed additional dependencies. Consumer fixture: TypeScript pass; Vite pass. This fixture check is distinct from the actual shadcn install receipt.

```tsx
"use client";

import "./components/ui/tidal.css";

import { useState } from "react";

import { TidalRatingInput } from "./components/ui/rating-input";

import "./components/ui/rating-input.css";



const tidalExampleStyles = ".tidal-scope .rating-input-demo {\n  width: 100%;\n  max-width: 380px;\n  min-width: 0;\n}\n.tidal-scope .rating-input-demo > button {\n  display: block;\n  min-height: 44px;\n  min-width: 44px;\n  border: 1px solid var(--t-ink);\n  border-radius: 9px;\n  background: var(--t-ink);\n  color: var(--t-surface);\n  font: 500 12px/1.5 inherit;\n  padding: 9px 16px;\n  margin-top: 18px;\n  cursor: pointer;\n}\n.tidal-scope .rating-input-demo > button:focus-visible {\n  outline: 2px solid var(--t-accent);\n  outline-offset: 3px;\n}\n.tidal-scope .rating-input-demo > p {\n  font-size: 11px;\n  line-height: 1.6;\n  color: var(--t-muted);\n  margin: 14px 0 0;\n  overflow-wrap: anywhere;\n}";

export function RatingInputDemo() {
  const [value, setValue] = useState<number | null>(4);
  const [message, setMessage] = useState(
    "Choose a rating, then save this local sample.",
  );
  return (
    <form
      className="rating-input-demo"
      onSubmit={(event) => {
        event.preventDefault();
        const data = new FormData(event.currentTarget);
        setMessage(`Local rating: ${data.get("rating") ?? "not rated"}.`);
      }}
    >
      <TidalRatingInput
        label="How was your experience?"
        description="Rate the product from one to five stars."
        name="rating"
        value={value}
        onValueChange={(next) => {
          setValue(next);
          setMessage("Choose Save rating to preview the form value.");
        }}
      />
      <button type="submit">Save rating</button>
      <p role="status">{message}</p>
    </form>
  );
}

export default function AgentExample() {
  return (
    <div className="tidal-scope" data-theme="light" dir="ltr">
      <style>{tidalExampleStyles}</style>
      <RatingInputDemo />
    </div>
  );
}

```

## Gotchas

- Keep field state, validation results, submission, and persistence in the host form workflow.

## Theme and accessibility

{"tokens":["--t-accent","--t-border","--t-border-strong","--t-canvas","--t-danger","--t-display","--t-ease-out","--t-ease-spring","--t-faint","--t-font","--t-ink","--t-line","--t-muted","--t-primary","--t-primary-contrast","--t-radius-card","--t-radius-control","--t-radius-overlay","--t-radius-panel","--t-ring","--t-shadow-lg","--t-shadow-soft","--t-soft","--t-subtle","--t-surface","--t-wash"],"darkMode":true}

{"keyboard":["Tab and Shift+Tab follow the component's native focus order.","Arrow-key behavior follows the exported composite-control implementation."],"aria":"The component wires labels and relationships from consumer-provided visible text or ARIA props; preserve those labels in production.","notes":"Verify focus visibility, text alternatives, contrast, and reduced motion in the final composition."}

Controlled number or null value, exact finite nonnegative numeric options with accessible labels, name/form participation, native radio arrow/Tab behavior, optional clear action, description/error and localized status text. Default options are one through five stars; selected score and cumulative fill remain visible without relying on color. Read-only radios are inert while a hidden mirror preserves form submission; disabled fields are omitted. Option onChange and clear button click handlers run first and can prevent the proposal. Cumulative fill follows option order, including zero. Root fieldset props/ref and per-input refs plus native clear-button props/ref are supported. Consumers own validation policy, submission, persistence and outcomes. No request or storage is bundled.
