Open In App

React Suite DatePicker ts:Placement Props

Improve
Improve
Like Article
Like
Save
Share
Report

React Suite is a popular front-end library with a set of React components that are designed for the middle platform and back-end products.

The user can choose or enter a date or time using the DatePicker component. These DatePickers can now be positioned in about 13 different ways. This placement can be any of the positions mentioned below:

DatePicker ts: Placement Props = ‘bottomStart’ | ‘bottomEnd’ | ‘topStart’ | ‘topEnd’ | ‘leftStart’ | ‘leftEnd’ | ‘rightStart’ | ‘rightEnd’ | ‘auto’ | ‘autoVerticalStart’ | ‘autoVerticalEnd’ | ‘autoHorizontalStart’ | ‘autoHorizontalEnd’;

Syntax:

// Import Statement
import { DatePicker } from 'rsuite';
// App.js file
Function App() {
    return (
        <DatePicker placeholder="" placement="auto" />
    );
}

Approach: Let us create a React project and install React Suite module. Then we will create a UI that will showcase React Suite DatePicker ts: Placement Props.

Creating React Project:

Step 1: To create a react app, you need to install react modules through npx command. “npx” is used instead of “npm” because you will be needing this command in your app’s lifecycle only once.

npx create-react-app project_name

Step 2: After creating your react project, move into the folder to perform different operations.

cd project_name

Step 3: After creating the ReactJS application, Install the required module using the following command:

npm install rsuite

Project Structure: After running the commands mentioned in the above steps, A similar project structure is visible if you open the project in an editor, as seen below. We will perform the code changes or add new components that the user makes in the source folder.

Project Structure

Example 1: We are creating a UI that shows different React Suite DatePicker ts:Placement props.

App.js




import React from 'react'
import '../node_modules/rsuite/dist/rsuite.min.css';
import { DatePicker } from 'rsuite';
  
export default function App() {
    return (
        <center>
            <div style={{ padding: 20 }}>
                <h2>GeeksforGeeks</h2>
                <h2 style={{ color: "green" }}>
                    React Suite DatePicker ts: Placement Props</h2>
                <br /><br /><br /><br />
                <DatePicker style={{ width: 300, marginRight: 200 }} 
                    placeholder="Bottom Start Date" 
                    placement="bottomStart" />
                <DatePicker style={{ width: 300 }}
                    placeholder="Bottom End Date " 
                    placement="bottomEnd" />
                <br /><br /><br />
                <DatePicker style={{ width: 300, marginRight: 200 }} 
                    placeholder="Right Start Date " 
                    placement="rightStart" />
                <DatePicker style={{ width: 300 }} 
                    placeholder="Left Start Date " 
                    placement="leftStart" />
                <br /><br /><br />
                <DatePicker style={{ width: 300, marginRight: 200 }} 
                    placeholder="Right End Date " 
                    placement="rightEnd" />
                <DatePicker style={{ width: 300 }} 
                    placeholder="Left End Date " 
                    placement="leftEnd" />
                <br /><br /><br />
                <DatePicker style={{ width: 300, marginRight: 200 }} 
                    placeholder="Top Start Date " 
                    placement="topStart" />
                <DatePicker style={{ width: 300 }} 
                    placeholder="Top End Date " 
                    placement="topEnd" />
            </div>
        </center>
    );
}


Step to Run Application: Run the application using the following command from the root directory of the project:

npm start

Output: Now open your browser and go to http://localhost:3000/, you will see the following output:

React Suite DatePickers Placement Props

Example 2: We are creating a UI that shows React Suite DatePicker ts: Placement props.

App.js




import React from 'react'
import '../node_modules/rsuite/dist/rsuite.min.css';
import { DatePicker } from 'rsuite';
  
export default function App() {
    return (
        <center>
            <div style={{ padding: 20 }}>
                <h2>GeeksforGeeks</h2>
                <h2 style={{ color: "green" }}>
                    React Suite DatePicker ts: Placement Props</h2>
                <br /><br />
                <DatePicker style={{ width: 300 }} 
                    placeholder="Auto Placed Date " 
                    placement="auto" />
                <br /><br /><br />
                <DatePicker style={{ width: 300, marginRight: 200 }} 
                    placeholder="Auto Vertical Start Date " 
                    placement="autoVerticalStart" />
                <DatePicker style={{ width: 300 }} 
                    placeholder="Auto Vertical End Date " 
                    placement="autoVerticalEnd" />
                <br /><br /><br />
                <DatePicker style={{ width: 300, marginRight: 200 }} 
                    placeholder="Auto Horizontal Start Date " 
                    placement="autoHorizontalStart" />
                <DatePicker style={{ width: 300 }} 
                    placeholder="Auto Horizontal End Date " 
                    placement="autoHorizontalEnd" />
            </div>
        </center>
    );
}


Output: Now open your browser and go to http://localhost:3000/, you will see the following output:

React Suite DatePickers Placement Props

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



Last Updated : 07 Jul, 2022
Like Article
Save Article
Previous
Next
Share your thoughts in the comments
Similar Reads