Un composant de notation React léger, simple et personnalisable qui utilise des icônes SVG comme symboles de notation.
1. Installez et importez le composant de notation.
# Yarn
$ yarn add @smastrom/react-rating
# NPM
$ npm i @smastrom/react-ratingimport { Rating } from '@smastrom/react-rating'
import '@smastrom/react-rating/style.css'
2. Créez le composant de notation dans votre application et initialisez l'état :
function App() {
const [rating, setRating] = useState(0) // Initial value
return <Rating style={{ maxWidth: 250 }} value={rating} onChange={setRating} />
}
3. Accessoires de composants disponibles.
value,
items = 5,
readOnly = false,
onChange = noop,
onHoverChange = noop,
onFocus = noop,
onBlur = noop,
isDisabled = false,
highlightOnlySelected = false,
orientation = OrientationProps.HORIZONTAL,
spaceBetween = Sizes.NONE,
spaceInside = Sizes.SMALL,
radius = Sizes.NONE,
transition = TransitionProps.COLORS,
itemStyles = defaultItemStyles,
isRequired = false,
halfFillMode = HFProps.SVG,
visibleLabelId,
visibleItemLabelIds,
invisibleItemLabels,
invisibleLabel = readOnly
? value > 0
? `Rated ${value} on ${items}`
: 'Not rated'
: 'Rating Selection',
resetLabel = 'Reset rating',
id,
className,
style,
Voir sur GitHub : https://github.com/SkyCaptainess/React-rating-components