Friday, October 24, 2025
HomeLanguagesReact Suite DatePicker ts:Range Props

React Suite DatePicker ts:Range Props

React suite is a library of React components, sensible UI design, and a friendly development experience. It is supported in all major browsers. It provides pre-built components of React which can be used easily in any web application. In this article, we’ll learn about React suite DatePicker ts:Range Props. 

The DatePicker Component is used to choose a time or date from the picker. To add a specific DatePicker label, value, or closeOverlay, we can add that by creating an interface using ts:Range prop.

React Suite DatePicker ts:Range Prop Properties:

  • label: It is used to add the range label of datepicker component.
  • value: It defines the range value that is defined by the user.
  • closeOverlay: It closes the picker component after selecting the date range.

Syntax:

<DatePicker
    ranges={[
        {
          label: 'Content',
          value: addDays(new Date(), -1),
          closeOverlay: boolean
        }
    ]}
/>

Creating React Application And Installing Module:

Step 1: Create a React application using the given command:

npm create-react-app projectname

Step 2: After creating your project, move to it using the given command:

cd projectname

Step 3: Now Install the rsuite node package using the given command:

npm install rsuite

Project Structure: Now your project structure should look like the following:

Project Structure

Example 1: Below example demonstrates the use of ts:Range interface for adding shortcuts to the DatePicker component.

App.js




import "rsuite/dist/rsuite.min.css";
import { DatePicker } from "rsuite";
import addDays from "date-fns/addDays";
  
export default function App() {
    return (
        <div>
            <div style={{ textAlign: "center" }}>
                <h2>neveropen</h2>
                <h4 style={{ color: "green" }}>
                    React Suite DatePicker ts:Range Prop
                </h4>
            </div>
            <div 
                style={{ 
                    padding: 20, 
                    textAlign: "center" 
                }}>
                <div>
                    <DatePicker
                        ranges={[
                            {
                                label: "yesterday",
                                value: addDays(new Date(), -1),
                            },
                            {
                                label: "today",
                                value: new Date(),
                            }
                        ]}
                    />
                </div>
            </div>
        </div>
    );
}


Steps to run the application: Execute the below-mentioned command from the root of your project folder to run the app.

npm start

Output:

 

Example 2: Another example demonstrating the use of ts:Range interface to define the shortcuts for the of DatePicker component.

App.js




import "rsuite/dist/rsuite.min.css";
import { DatePicker } from "rsuite";
import addDays from "date-fns/addDays";
import subDays from "date-fns/subDays";
  
export default function App() {
    return (
        <div>
            <div style={{ textAlign: "center" }}>
                <h2>neveropen</h2>
                <h4 style={{ color: "green" }}>
                    React Suite DatePicker ts:Range Prop
                </h4>
            </div>
            <div style={{ padding: 20, textAlign: "center" }}>
                <div>
                    <DatePicker
                        ranges={[
                            {
                                label: "yesterday",
                                value: addDays(new Date(), -1),
                            },
                            {
                                label: "today",
                                value: new Date(),
                            },
                            {
                                label: "Prev Day",
                                closeOverlay: true,
                                value: (date) => {
                                    return subDays(date, 1);
                                },
                            },
                        ]}
                    />
                </div>
            </div>
        </div>
    );
}


Output:

 

Reference: https://rsuitejs.com/components/date-picker/#code-ts-range-code

Whether you’re preparing for your first job interview or aiming to upskill in this ever-evolving tech landscape, neveropen Courses are your key to success. We provide top-quality content at affordable prices, all geared towards accelerating your growth in a time-bound manner. Join the millions we’ve already empowered, and we’re here to do the same for you. Don’t miss out – check it out now!
RELATED ARTICLES

Most Popular

Dominic
32361 POSTS0 COMMENTS
Milvus
88 POSTS0 COMMENTS
Nango Kala
6728 POSTS0 COMMENTS
Nicole Veronica
11892 POSTS0 COMMENTS
Nokonwaba Nkukhwana
11954 POSTS0 COMMENTS
Shaida Kate Naidoo
6852 POSTS0 COMMENTS
Ted Musemwa
7113 POSTS0 COMMENTS
Thapelo Manthata
6805 POSTS0 COMMENTS
Umr Jansen
6801 POSTS0 COMMENTS