Reputation: 369
I am trying to add an SVG icon into react-datepicker
input but seems like I can't add it with css input so I created a new element for icon and trying to create a function when click into icon the react-datepicker
will open.
Here is my following code:
<DatePicker
selected={dateInput}
onChange={(date) => setDateInput(date)}
minDate={moment().toDate()}
showPopperArrow={false}
/>
<span>
<CalendarIcon />
</span>
Here is my project look like:
Upvotes: 2
Views: 2705
Reputation: 5462
Can you try wrapping <DatePicker>
& icon within the label?
Code will look like:
<label>
<DatePicker
selected={dateInput}
onChange={(date) => setDateInput(date)}
minDate={moment().toDate()}
showPopperArrow={false}/>
<CalendarIcon />
</label>
Upvotes: 3