How can I help you?
Selection in React Rating Component
21 Feb 20267 minutes to read
The Rating component enables users to select a rating value through visual interaction or code. It supports a minimum value setting, reset functionality, and customization options for selection behavior.
// Import the Rating.
import { RatingComponent } from '@syncfusion/ej2-react-inputs';
import * as React from 'react';
import * as ReactDom from 'react-dom';
// To render Rating.
function App() {
return (<div className='wrap'>
<RatingComponent id='rating' value={3}></RatingComponent>
</div>);
}
export default App;
ReactDom.render(<App />, document.getElementById('element'));// Import the Rating.
import { RatingComponent } from '@syncfusion/ej2-react-inputs';
import * as React from 'react';
import * as ReactDom from 'react-dom';
// To render Rating.
function App() {
return (
<div className='wrap'>
<RatingComponent id='rating' value={3} ></RatingComponent>
</div>
);
}
export default App;
ReactDom.render(<App />,document.getElementById('element'));Min value
Set the minimum possible rating value using the min property. For example, if min is set to 2, users cannot select a rating lower than 2.
// Import the Rating.
import { RatingComponent } from '@syncfusion/ej2-react-inputs';
import * as React from 'react';
import * as ReactDom from 'react-dom';
// To render Rating.
function App() {
return (<div className='wrap'>
<RatingComponent id='rating' min={2}></RatingComponent>
</div>);
}
export default App;
ReactDom.render(<App />, document.getElementById('element'));// Import the Rating.
import { RatingComponent } from '@syncfusion/ej2-react-inputs';
import * as React from 'react';
import * as ReactDom from 'react-dom';
// To render Rating.
function App() {
return (
<div className='wrap'>
<RatingComponent id='rating' min={2} ></RatingComponent>
</div>
);
}
export default App;
ReactDom.render(<App />,document.getElementById('element'));Single selection
Enable single selection mode using the enableSingleSelection property. When set to true, only one item can be selected at a time; all other items are unselected.
// Import the Rating.
import { RatingComponent } from '@syncfusion/ej2-react-inputs';
import * as React from 'react';
import * as ReactDom from 'react-dom';
// To render Rating.
function App() {
return (<div className='wrap'>
<RatingComponent id='rating' value={3} enableSingleSelection={true}></RatingComponent>
</div>);
}
export default App;
ReactDom.render(<App />, document.getElementById('element'));// Import the Rating.
import { RatingComponent } from '@syncfusion/ej2-react-inputs';
import * as React from 'react';
import * as ReactDom from 'react-dom';
// To render Rating.
function App() {
return (
<div className='wrap'>
<RatingComponent id='rating' value={3} enableSingleSelection={true} ></RatingComponent>
</div>
);
}
export default App;
ReactDom.render(<App />,document.getElementById('element'));Show or hide reset button
Display a reset button by setting the allowReset property to true. This allows users to reset the rating value to its default state.
// Import the Rating.
import { RatingComponent } from '@syncfusion/ej2-react-inputs';
import * as React from 'react';
import * as ReactDom from 'react-dom';
// To render Rating.
function App() {
return (<div className='wrap'>
<RatingComponent id='rating' value={3} allowReset={true}></RatingComponent>
</div>);
}
export default App;
ReactDom.render(<App />, document.getElementById('element'));// Import the Rating.
import { RatingComponent } from '@syncfusion/ej2-react-inputs';
import * as React from 'react';
import * as ReactDom from 'react-dom';
// To render Rating.
function App() {
return (
<div className='wrap'>
<RatingComponent id='rating' value={3} allowReset={true} ></RatingComponent>
</div>
);
}
export default App;
ReactDom.render(<App />,document.getElementById('element'));