Use the function chi.datepicker(elem)
to instantiate a new date picker component in the input of type
text element passed as a parameter. This component uses the
Day.js library.
Input of type text should be used and any other type, including type date, will be converted into type text.
<div class="m-form__item">
<label class="a-label" for="datepicker-1">Range label</label>
<div class="m-input__wrapper -icon--right">
<input id="datepicker-1" type="text" class="a-input" placeholder="MM/DD/YYYY" value="">
<div class="a-icon -text--muted">
<svg>
<use xlink:href="#icon-date"></use>
</svg>
</div>
</div>
</div>
<script>chi.datePicker(document.getElementById('datepicker-1'));</script>
<div class="m-form__item">
<label class="a-label" for="datepicker-2">Date</label>
<div class="m-input__wrapper -icon--right">
<input id="datepicker-2" type="text" class="a-input" value="01/24/2019" min="01/14/2019" max="02/07/2019" placeholder="MM/DD/YYYY">
<div class="a-icon -text--muted">
<svg>
<use xlink:href="#icon-date"></use>
</svg>
</div>
</div>
</div>
<script>chi.datePicker(document.getElementById('datepicker-2'));</script>
This component accepts options to configure its behavior.
<div class="m-form__item">
<label class="a-label" for="datepicker-3">Date</label>
<div class="m-input__wrapper -icon--right">
<input id="datepicker-3" type="text" class="a-input" placeholder="MM/DD/YYYY" value="">
<div class="a-icon -text--muted">
<svg>
<use xlink:href="#icon-date"></use>
</svg>
</div>
</div>
</div>
<script>
chi.datePicker(
document.getElementById('datepicker-3'),
{
date: '01/24/2019',
min: '01/24/2019'
}
);
</script>