Rating
Star rating input or read-only display.
Code
import * as React from 'react';
import { Rating, Stack } from '@fruit-labs/design';
export default function Demo() {
return (
<Stack direction="row" gap={6} align="center">
<Rating defaultValue={4} showValue />
<Rating defaultValue={3} readOnly size={16} />
</Stack>
);
}Read only
import { Rating } from '@fruit-labs/design';
export default function Example() {
return (
<div style={{ display: 'flex', flexWrap: 'wrap', gap: 12, alignItems: 'center' }}>
<Rating value={4} readOnly showValue label="Average rating" />
</div>
);
}Install
From npm:
npm install @fruit-labs/design
import { Rating } from '@fruit-labs/design';Or copy the TypeScript source into your project:
npx shadcn@latest add https://design.fruitlabs.online/r/rating.jsonGuidelines
readOnlyfor display;showValueshows the number.
Props
| Prop | Type | Required |
|---|---|---|
value | number | No |
defaultValue | number | No |
onChange | (v: number) => void | No |
max | number | No |
readOnly | boolean | No |
clearable | boolean | No |
showValue | boolean | No |
size | number | No |
label | string | No |
className | string | No |