# Rating scale using numerical buttons

> Rating scale using numerical buttons

A shadcn/ui block from the [@reui](https://reui.io) registry, listed on [shadcn.exchange](https://shadcn.exchange/r/reui/c-button-group-25).

- Page, with a live preview: https://shadcn.exchange/r/reui/c-button-group-25
- Screenshot: https://abzjhwgwpdpz7ua5.public.blob.vercel-storage.com/shots/reui/c-button-group-25-light-a1e49662a2bc9c15.png
- Registry item: https://reui.io/r/new-york-v4/c-button-group-25.json
- Listed: 2026-10-13, source last changed 2026-10-13

## Install

```bash
npx shadcn@latest add https://reui.io/r/new-york-v4/c-button-group-25.json
```

Run it in a project that has shadcn/ui set up. It adds the files below and installs what they depend on.

## Dependencies

- npm packages: `cn`
- Registry items: `button`, `button-group`

## Files

### `c-button-group-25.tsx`

```tsx
"use client"

import { useState } from "react"

import { cn } from "cn"
import { Button } from "@/components/ui/button"
import { ButtonGroup } from "@/components/ui/button-group"

export function Pattern() {
  const [rating, setRating] = useState<number | null>(null)

  return (
    <div className="space-y-3">
      <p className="text-sm font-medium">How likely are you to recommend us?</p>
      <ButtonGroup>
        {[1, 2, 3, 4, 5, 6, 7, 8, 9, 10].map((n) => (
          <Button
            key={n}
            variant="outline"
            size="icon-sm"
            onClick={() => setRating(n)}
            className={cn(
              rating === n &&
                "bg-primary hover:bg-primary hover:text-primary-foreground hover:border-primary text-primary-foreground border-primary"
            )}
          >
            {n}
          </Button>
        ))}
      </ButtonGroup>
      <div className="text-muted-foreground flex justify-between text-xs">
        <span>Not likely</span>
        <span>Very likely</span>
      </div>
    </div>
  )
}
```
