How to put float label in KendoReact DatePicker?
like https://www.telerik.com/kendo-react-ui/components/dropdowns/floating-labels/
How to put float label in KendoReact DatePicker?
like https://www.telerik.com/kendo-react-ui/components/dropdowns/floating-labels/
I suggest using a custom place holder and conditional rendering. Kendo uses classes to get the style of a floating label, the nested span will achieve that. I have added the code snippet I tried, but since I am not familiar with React, I could not get the conditional rendering to work.
import * as React from 'react';
import * as ReactDOM from 'react-dom';
import { dataProducts, dataCategories, dataOrders } from './data';
import { DateInput, Calendar, DatePicker, TimePicker, MultiViewCalendar, DateRangePicker } from '@progress/kendo-react-dateinputs';
class App extends React.Component {
render() {
const isFocused = false;
return (
<div>
<div>
<p>DatePicker</p>
{isFocused
? <span class="k-textbox-container k-state-focused k-state-empty"><span class="k-label">Select Order Date</span></span>
: null}
<div onFocus = {this.onFocusDatePickerInput} onBlur = {this.onBlurDatePickerInput} >
<DatePicker format="MM dd yyyy" formatPlaceholder={{ year: 'Date', month: 'Select', day: 'Order' }}
onChange={this.changeDate} />
</div>
</div>
</div>
);
}
changeDate = (event) => {
console.log(event.value)
if(event.value){
this.format= "MM/dd/yyyy";
this.setState({ value: event.value });
}
}
onFocusDatePickerInput = () =>
{
this.isFocused = true;
console.log(this.isFocused)
}
onBlurDatePickerInput = () =>
{
this.isFocused = false;
console.log(this.isFocused)
}
}
ReactDOM.render(
<App />,
document.querySelector('my-app')
);