Deprecated as of Novemeber 2024. Please use New Library(B_Block v2.0)

Date Picker Component

Date Picker component that can be used to select date input from the user.

Props

PropertyTypeDescription
placeholderstringThe placeholder text displayed in the input field
valueDateThe value of the input field, as a Date object
onChange(event: ChangeEvent<HTMLInputElement>) => voidThe event handler for when the value of the input field changes
classNamestringThe CSS class name(s) applied to the input field
namestringThe name of the input field
disabledbooleanWhether the input field is disabled or not
mindatesets the minimum date
maxdatesets the maximum date

Usage

Here's an example of how to use the Date Picker component:

Functional Component
App.tsx
import React from 'react';
import './App.css';
import { DatePicker } from 'gbs-fwk-buildingBlock';
 
function App() {
  const [date, setDate] = useState();
  handleDateChange = (event) => {
    setDate(event.target.value);
  };
 
  return (
    <div className="App">
      <DatePicker
        placeholder="Date"
        onChange={this.handleDateChange}
        value={date}
      />
    </div>
  );
}
 
export default App;
Class Component
App.tsx
import React from 'react';
import './App.css';
import { DatePicker } from 'gbs-fwk-buildingblock';
 
class App extends React.Component {
  constructor(props) {
    super(props);
    this.state = {
      date: undefined,
    };
  }
 
  handleDateChange = (event) => {
    this.setState({ date: event.target.value });
  };
 
  render() {
    return (
      <div className="App">
        <DatePicker placeholder="Date" onChange={this.handleDateChange} />
      </div>
    );
  }
}
 
export default App;