# Rating (UI SDK): Form

> With a `name`, the score submits with the form. `required` blocks submission until there’s a score, with the browser’s own message.

Canonical: https://hextaui.com/docs/ui-sdk-rating/examples/form

Component docs: https://hextaui.com/docs/ui-sdk-rating

## Add this example

```bash
npx shadcn@latest add https://hextaui.com/r/ui-sdk-rating-form.json
```

This adds `components/examples/ui-sdk-rating/form.tsx` with the Rating component and the HextaUI theme tokens.

## Source

```tsx title="components/examples/ui-sdk-rating/form.tsx"
"use client"

import * as React from "react"

import { Button } from "@/components/ui/button"
import { Rating, RatingItem } from "@/components/ui/ui-sdk-rating"

function UiSdkRatingForm() {
  const [submitted, setSubmitted] = React.useState<string | null>(null)

  return (
    <form
      className="flex flex-col items-start gap-3"
      onSubmit={(event) => {
        event.preventDefault()
        setSubmitted(String(new FormData(event.currentTarget).get("score")))
      }}
      onReset={() => setSubmitted(null)}
    >
      <div className="flex flex-col gap-1.5">
        <span id="rating-form-label" className="text-sm font-medium">
          Rate this answer
        </span>
        <Rating aria-labelledby="rating-form-label" name="score" required>
          <RatingItem />
        </Rating>
      </div>
      <div className="flex gap-2">
        <Button type="submit" size="sm">
          Submit
        </Button>
        <Button type="reset" variant="outline" size="sm">
          Reset
        </Button>
      </div>
      <p role="status" className="text-sm text-muted-foreground">
        {submitted ? "Submitted score=" + submitted : "Nothing submitted yet."}
      </p>
    </form>
  )
}

export { UiSdkRatingForm }
```

## Props in this example

### Rating

| Prop | Type | Default | Description |
| --- | --- | --- | --- |
| `required` | `boolean` | `false` |  |
| `name` | `string` | – |  |

## More Rating examples

- [Half stars](https://hextaui.com/docs/ui-sdk-rating/examples/half)
- [Read-only](https://hextaui.com/docs/ui-sdk-rating/examples/read-only)
- [Sizes](https://hextaui.com/docs/ui-sdk-rating/examples/sizes)
- [Deselectable](https://hextaui.com/docs/ui-sdk-rating/examples/deselectable)
- [Controlled](https://hextaui.com/docs/ui-sdk-rating/examples/controlled)
- [Custom icon](https://hextaui.com/docs/ui-sdk-rating/examples/custom-icon)
- [Disabled](https://hextaui.com/docs/ui-sdk-rating/examples/disabled)
- [Right to left](https://hextaui.com/docs/ui-sdk-rating/examples/rtl)
