Skip to Content
Kenat is a work in progress project πŸ‘¨πŸ»β€πŸ’»
Documentation🎨 Kenat UIπŸ“… Date Picker

Date Picker UI

πŸ“† useDatePicker()

useDatePicker is a headless hook for building an Ethiopian date picker. It manages:

  • Selection state
  • Dropdown toggle
  • Grid navigation
  • Formatted display

βœ… Usage

import { useDatePicker } from 'kenat-ui' const { state, actions } = useDatePicker()

βœ… state object

  • selectedDate: { year, month, day }
  • formatted: "YYYY/MM/DD" string
  • open: true | false (dropdown status)
  • grid: Full month grid
  • headers, days: Grid data
  • inputRef: Ref for the input field

βœ… actions object

  • toggleOpen(), close()
  • selectDate(day)
  • nextMonth(), prevMonth()
  • nextYear(), prevYear()

βœ… Example

<input type="text" readOnly ref={state.inputRef} value={state.formatted} onClick={actions.toggleOpen} /> {state.open && ( <div className="calendar-dropdown"> <div>{state.grid.monthName} {state.grid.year}</div> <div className="grid grid-cols-7"> {state.days.map((day, i) => day ? ( <button key={i} onClick={() => actions.selectDate(day)}> {day.ethiopian.day} </button> ) : <div key={i} /> )} </div> </div> )}
Last updated on