Knit UI
GitHub

Playground

Loading playground…

false
true
false
false
Playground
<Rating
  count={5}
  size="sm"
  fractions={1}
  readOnly={false}
  allowClear
  highlightSelectedOnly={false}
  disabled={false}
/>

Examples

Sizes

All named sizes side by side, from xxs to xxl.

Loading example…

SizesSourceStorybook

Theme Accent

Theme-driven accent color via Tamagui's theme prop.

Loading example…

Theme AccentSourceStorybook

Read Only

Read-only display — no interactive segments are rendered, hover has no effect.

Loading example…

Read OnlySourceStorybook

Disabled

Disabled state — reduced opacity and pointer events turned off.

Loading example…

DisabledSourceStorybook

Half Stars

Half-star precision via fractions={2} — hover and select at 0.5 intervals.

Loading example…

Half StarsSourceStorybook

Highlight Selected Only

Highlights only the selected symbol rather than all symbols up to it.

Loading example…

Highlight Selected OnlySourceStorybook

Shadows

Elevation shadow ladder applied via the inherited shadow prop.

Loading example…

ShadowsSourceStorybook

Custom Symbols

Custom symbol nodes replace the default star glyphs for empty and filled states.

Loading example…

Custom SymbolsSourceStorybook

Custom Count

Custom count — ten-point scale with a heart theme.

Loading example…

Custom CountSourceStorybook

Controlled

Fully controlled — value is managed in React state; onChange keeps it in sync.

Loading example…

ControlledSourceStorybook

Matrix

Dense visual regression matrix across sizes and common states.

Loading example…

MatrixSourceStorybook

Styles

Per-slot styles targets individual parts — here the root and each symbol.

Loading example…

StylesSourceStorybook

Props

PropTypeDefaultDescription
allowClearboolean | undefinedtrueClicking the current value clears it to 0.
countnumber | undefined5Number of symbols rendered.
defaultValuenumber | undefinedUncontrolled initial value.
disabled systemboolean | undefinedfalse
emptySymbolReactNode | ((value: number) => ReactNode)Symbol shown for the unfilled part. Node or `(value) => node`.
formstring | undefinedAssociated form id for the hidden input.
fractionsnumber | undefined1Sub-divisions per symbol (e.g. 2 = half-stars).
fullSymbolReactNode | ((value: number) => ReactNode)Symbol shown for the filled part. Node or `(value) => node`.
getSymbolLabel((value: number) => string) | undefinedString(value)Generate the `aria-label` for each symbol.
highlightSelectedOnlyboolean | undefinedfalseHighlight only the selected symbol, not all up to it.
namestring | undefinedHidden input name for web form submission.
onChange((value: number) => void) | undefinedCalled when the value changes.
onHover((value: number) => void) | undefinedCalled as the pointer moves over symbols; receives `-1` on leave.
readOnlyboolean | undefinedfalsePrevent user interaction.
shadow system"xs" | "sm" | "md" | "lg" | "xl" | "xxs" | "xxl" | undefined
size systemRatingSize | undefined
xxs · xs · sm · md · lg · xl · xxl
"sm"Symbol size — either a named key or a custom pixel value.
styles systemSlotStyles<RatingStyles> | undefinedPer-slot style sugar — props spread onto the matching styled part.
theme systemThemeName | null | undefined
unset · blue · red · green · yellow · pink · gray
Applies a theme to this element
valuenumber | undefinedControlled value.

Style slots

Every part of Rating can be styled through the styles prop. Explicit props on the component always win over slot styles.

SlotUsage
rootstyles={{ root: { … } }}
segmentstyles={{ segment: { … } }}
symbolstyles={{ symbol: { … } }}
Accessibility & DOM props (2)
PropType
keyKey | null | undefined
refRef<TamaguiElement> | undefined

Plus 497 inherited style props from Box — the full Tamagui/React Native style surface, including token shorthands like p, mx, bg and c. See Tokens for the scales they accept, or the full list.