The auto-close attribute controls when the calendar automatically closes.
Combined with button visibility options, you can create various interaction patterns.
AC01 Auto-Close on Selection (Default)
Calendar closes immediately when selection is complete
Live Demo
Select two dates - calendar closes automatically
Code Examples
Details
Behavior
- Calendar closes when selection completes (both dates selected)
- Input value updates immediately
- Events fire immediately
Use Cases
- Quick selection - Minimal user interaction
- Mobile-friendly - Less screen time
- Simple forms - One-step date selection
Key Option
auto-close="selection"- Default value
AC02 Auto-Close on Apply Only
Selection is deferred until Apply button is clicked
Live Demo
Select dates, then click Apply to confirm
Code Examples
Details
Behavior
- Calendar shows Apply button automatically
- Selection is visual only until Apply is clicked
- Input value updates on Apply
- Events fire on Apply
- Closing without Apply reverts selection
Use Cases
- Review before commit - User can verify selection
- Complex workflows - Allow adjustments
- Prevent accidents - Explicit confirmation
Key Option
auto-close="apply"- Defers selection to Apply
AC03 Never Auto-Close
Calendar stays open, selection commits immediately
Live Demo
Calendar stays open - click Apply or outside to close
Code Examples
Details
Behavior
- Calendar never closes automatically on selection
- Selection commits immediately to input
- Apply button closes the calendar (optional)
- Click outside also closes
Use Cases
- Multiple adjustments - User can refine selection
- Exploration - Browse dates freely
- Dashboard widgets - Persistent calendar
Key Options
auto-close="never"- Prevents auto-closeshow-apply-button="true"- Provides explicit close
AC04 Button Visibility Control
Customize which buttons appear in the calendar footer
Live Demo
Code Examples
Details
Button Options
show-today-button- Jump to today (default: true)show-clear-button- Clear selection (default: true)show-apply-button- Confirm/close (default: false)
Common Patterns
| Pattern | auto-close | Buttons |
|---|---|---|
| Quick select | selection | None or Today only |
| Confirm flow | apply | Apply required |
| Exploration | never | All buttons |
Notes
With auto-close="apply", the Apply button is always shown
regardless of show-apply-button setting.
AC05 Custom Preset Buttons
Programmatically set dates with custom action buttons
Code Example
Best Practices
Required Steps
- Set
selectedStartDateandselectedEndDate - Clear
focusedDayIndex = nullto remove old focus indicator - Call
renderCalendar()to update display - Call
updateSummary()to update the summary text
Why Clear focusedDayIndex?
If a user clicks a date before using a preset button, the focus indicator
(dotted border) remains on that date. Setting focusedDayIndex = null clears this visual state so only the new range is highlighted.
Details
Action Button Properties
action: 'custom'- Custom onClick handlertext- Button labelonClick(picker)- Handler receives picker instance
Built-in Actions
action: 'today'- Jump to todayaction: 'clear'- Clear selectionaction: 'apply'- Apply and close
Tip
The Apply button will commit any selected dates to the input, even if they were set programmatically via custom buttons.
AC06 Mode Comparison
Quick reference for auto-close behavior
Behavior Matrix
| Mode | Closes on Selection | Input Updates | Events Fire |
|---|---|---|---|
selection | Yes (immediately) | Immediately | Immediately |
apply | On Apply click | On Apply | On Apply |
never | Manual only | Immediately | Immediately |