# Airbnb · Widen the travel date range

Enter check-in and checkout dates, then choose how much the dates can move. A three-day margin on either side also surfaces places available close to the original dates.

[Official source](https://www.airbnb.com/help/article/252)

## Related motion · Date Range Picker

# Date Range Picker

Two selected dates define a period across one or more months.

## Try it

Choose the two ends of a period, changing months if needed, and check the highlighted range.

## Interaction details

The first date sets an anchor and the second confirms the range. Moving the pointer or keyboard focus previews the interval. Count both endpoints and normalize dates selected in reverse order.

## Platform controls

- iOS · Tap the first and last dates. Use the month arrows for a range that crosses into another month.
- Android · Tap two dates to set the range, then try clearing the selection.
- PC · Move with the arrow keys and press Enter or Space to select each end. Page Up and Page Down change months.

## Where to use it

Booking dates, production schedules, and report filters.

## Implementation prompt

> Preview the interval while choosing an end date and show the inclusive total after selection.

## Sources and credits

[Adobe React Aria · RangeCalendar](<https://react-aria.adobe.com/RangeCalendar>)

## Standalone HTML

Save the code below as an HTML file and open it in your browser. The example works offline.

```html
<!doctype html>
<html lang="en"><head><script>if(new URLSearchParams(location.search).get('reduce')==='1')document.documentElement.classList.add('motion-reduced');</script><meta charset="utf-8"><meta name="viewport" content="width=device-width,initial-scale=1"><title>Studio booking calendar</title><style>
*{box-sizing:border-box}body{margin:0;min-height:100vh;display:grid;align-items:center;background:#dce5e9;color:#182e41;font:15px/1.4 system-ui,sans-serif}main{width:min(735px,100%);margin:auto;padding:clamp(10px,4%,34px)}.planner{display:grid;grid-template-columns:minmax(145px,.7fr) minmax(0,1.55fr);overflow:hidden;background:#fffdf7;border:1px solid #9baeb4;box-shadow:0 9px 28px #42595d20}.record{background:#24455c;color:#fff8e8;display:flex;flex-direction:column;padding:clamp(13px,3vw,28px);gap:12px}.record h1{font-size:clamp(20px,3vw,27px);margin:0;letter-spacing:-.06em;word-break:keep-all}.dates{margin:auto 0 0;display:grid;gap:4px}.dates small{color:#d5e4e9}.dates strong{font:400 clamp(31px,5vw,54px)/1.13 Georgia,serif;font-variant-numeric:tabular-nums}.record .clear{border:0;background:transparent;color:#fff8e8;border-bottom:1px solid #a9c1cd;align-self:flex-start;padding:3px 0;min-height:44px;font:inherit;font-size:13px;cursor:pointer}.cal{padding:clamp(12px,3vw,23px)}.month,.nav{display:flex;align-items:center;gap:6px}.month{justify-content:space-between}.month h2{margin:0;font:700 clamp(19px,3vw,26px)/1.25 system-ui;letter-spacing:-.045em}.nav button{border:1px solid #9aaab1;background:#faf9f1;color:#263e4c;min-width:40px;min-height:42px;font-size:19px;cursor:pointer}.nav button:disabled{opacity:.4;cursor:default}table{width:100%;table-layout:fixed;text-align:center;border-collapse:separate;border-spacing:0 4px;margin:6px 0 0}th{color:#536877;font-weight:500;font-size:12px}td{padding:0}td button{width:100%;height:39px;border:none;border-radius:0;background:#f7f7ef;color:#253b4a;font:600 15px/1.2 ui-monospace,monospace;cursor:pointer;transition:background-color .14s}td button.inside{background:#cadbd8;color:#173d41}td button.edge{background:#275450;color:white}td button.start{border-radius:20px 0 0 20px}td button.end{border-radius:0 20px 20px 0}td button.start.end{border-radius:20px}td button.draft.inside:not(.edge){background:#deebe6}.hint{margin:3px 0 0;min-height:2.9em;font-size:13px;color:#40596b}button:focus-visible{outline:3px solid #b45119;outline-offset:-3px}.record button:focus-visible{outline-color:#ffc884}.motion-reduced td button{transition:none}@media(prefers-reduced-motion:reduce){td button{transition:none}}@media(max-width:500px){.planner{grid-template-columns:1fr}.record{display:grid;grid-template-columns:1fr auto;gap:3px 14px;padding:11px 14px}.record h1{grid-column:1/-1;font-size:19px}.dates{display:flex;align-items:baseline;gap:7px}.dates strong{font-size:25px}.record .clear{padding:0}.cal{padding:13px 10px}.nav button{min-height:44px}.hint{min-height:0}.dates small{font-size:12px}td button{height:40px}}
</style></head><body><main><div class="planner"><header class="record"><h1>Studio booking calendar</h1><p class="dates"><small>Selected dates</small><strong id="dayCount">4 days</strong></p><button class="clear" type="button" id="clear">Clear dates</button></header><section class="cal" aria-labelledby="month"><div class="month"><h2 id="month" aria-live="polite"></h2><div class="nav"><button type="button" id="prev" aria-label="Previous month">‹</button><button type="button" id="next" aria-label="Next month">›</button></div></div><table aria-label="Select studio dates"><thead><tr><th scope="col">Sun</th><th scope="col">Mon</th><th scope="col">Tue</th><th scope="col">Wed</th><th scope="col">Thu</th><th scope="col">Fri</th><th scope="col">Sat</th></tr></thead><tbody id="days"></tbody></table><p class="hint" role="status" id="hint"></p></section></div></main>
<script>
(()=>{
  const get=id=>document.getElementById(id),days=get('days'),day=86400000;
  const min=Date.UTC(1900,0,1),max=Date.UTC(2199,11,31),first=Date.UTC(2026,10,17);
  let start=first,end=first+3*day,point=first,preview=null,month=Date.UTC(2026,10,1);
  const y=d=>new Date(d).getUTCFullYear(),m=d=>new Date(d).getUTCMonth(),n=d=>new Date(d).getUTCDate();
  const short = d => new Intl.DateTimeFormat('en-US', {month:'short',day:'numeric',timeZone:'UTC'}).format(d);
  const full = d => new Intl.DateTimeFormat('en-US', {month:'long',day:'numeric',year:'numeric',timeZone:'UTC'}).format(d);
  function bound(d){return Math.max(min,Math.min(max,d));}
  function shifted(d,months){const last=Date.UTC(y(d),m(d)+months+1,0);return bound(Date.UTC(y(last),m(last),Math.min(n(last),n(d))));}
  function paint(){
    const last=end??preview??start;
    const lo=start===null?null:Math.min(start,last), hi=start===null?null:Math.max(start,last);
    for(const btn of days.querySelectorAll('button')){
      const date=Number(btn.dataset.day),inRange=lo!==null&&date>=lo&&date<=hi;
      btn.classList.toggle('inside',inRange);btn.classList.toggle('edge',date===lo||date===hi);btn.classList.toggle('start',date===lo);btn.classList.toggle('end',date===hi);btn.classList.toggle('draft',end===null);
      btn.setAttribute('aria-pressed',String(start!==null&&(end===null?date===start:inRange)));
      btn.tabIndex=date===point?0:-1;
    }
    get('dayCount').textContent=lo===null?'—':((hi-lo)/day+1)+(hi===lo?' day':' days');
    const message=start===null?'Choose a start date and then an end date.':end===null?'Start: '+short(start)+'. Choose an end date.':full(start)+' — '+full(end);
    if(get('hint').textContent!==message)get('hint').textContent=message;
  }
  function render(focus){
    days.replaceChildren();
    const total=n(Date.UTC(y(month),m(month)+1,0)),offset=new Date(month).getUTCDay(),cellCount=Math.ceil((offset+total)/7)*7;
    for(let index=0;index<cellCount;index++){
      let row=index%7===0?days.insertRow():days.lastElementChild;
      const cell=row.insertCell(),num=index-offset+1;
      if(num<1||num>total)continue;
      const d=month+(num-1)*day,b=document.createElement('button');b.type='button';b.dataset.day=String(d);b.textContent=num;b.setAttribute('aria-label',full(d));cell.append(b);
    }
    get('month').textContent=new Intl.DateTimeFormat('en-US',{month:'long',year:'numeric',timeZone:'UTC'}).format(month);
    get('prev').disabled=month===min;get('next').disabled=y(month)===2199&&m(month)===11;
    paint();if(focus)days.querySelector('[tabindex="0"]')?.focus();
  }
  function move(date,focus){
    point=bound(date);const next=Date.UTC(y(point),m(point),1);
    preview=end===null?point:null;
    if(next!==month){month=next;render(focus);}else{paint();if(focus)days.querySelector('[tabindex="0"]')?.focus();}
  }
  days.addEventListener('click',e=>{
    const b=e.target.closest('button');if(!b)return;
    point=Number(b.dataset.day);
    if(start===null||end!==null){start=point;end=null;preview=point;}
    else{end=Math.max(start,point);start=Math.min(start,point);preview=null;}
    paint();
  });
  days.addEventListener('pointerover',e=>{const b=e.target.closest('button');if(b&&start!==null&&end===null){preview=Number(b.dataset.day);paint();}});
  days.addEventListener('pointerleave',()=>{if(end===null){preview=point;paint();}});
  days.addEventListener('keydown',e=>{
    const b=e.target.closest('button');if(!b)return;
    const d=Number(b.dataset.day),weekday=new Date(d).getUTCDay();
    const values={ArrowLeft:d-day,ArrowRight:d+day,ArrowUp:d-7*day,ArrowDown:d+7*day,Home:d-weekday*day,End:d+(6-weekday)*day,PageUp:shifted(d,-1),PageDown:shifted(d,1)};
    if(!Object.hasOwn(values,e.key))return;e.preventDefault();move(values[e.key],true);
  });
  get('prev').addEventListener('click',()=>move(shifted(point,-1),false));get('next').addEventListener('click',()=>move(shifted(point,1),false));
  get('clear').addEventListener('click',()=>{start=end=preview=null;paint();days.querySelector('[tabindex="0"]').focus();});render(false);
})();
</script></body></html>
```
