Search form
The dates-and-guests search for your home page. A search opens your booking page.
- Box
data-pms-booking="search-form"- Goes on
- Any page — usually the home page
- Drawn
- On your page, in a shadow root
- Own HTML instead
- Yes — recommended
The ready component
One line to paste. It wears the property’s branding from the PMS until your site’s stylesheet says otherwise.
- Place the script once, on every page that shows a component — see Install the script.
- Paste the component where it should appear.
<div data-pms-booking="search-form" data-promo="off"></div>Live preview on a sample hotel — invented rooms and prices, placeholder pictures. Open in a new tab
The live preview runs only when these docs are opened on a developer's own machine.
<div data-pms-booking="search-form" data-promo="off"></div>Settings
What the component shows and where it leads — attributes on its box.
| Attribute | Values | What it does |
|---|---|---|
data-title, data-subtitle | text, up to 80 characters | Your own heading and the line under it, instead of ours. |
data-cta | text, up to 80 characters | Your own words on the search button. |
data-promo | "off" | off hides the promo-code field. |
How it looks — colours, corners, fonts — is not an attribute. Your site’s stylesheet sets it with CSS variables: see Styling.
In a narrow column
The form lays itself out by the width of its own box, not by the width of the screen. In a box 1010px wide or more it is one bar: the title, the fields and the button in a row. In a narrower box the title goes on top and the fields share a grid that goes from four columns to one as the box narrows; under 456px each field and the button take a full row. So in a 320px sidebar on a wide screen it is the stacked form, not a squeezed bar.
Its calendar is the exception: the calendar opens over the whole page, so it follows the screen — one scrolling column of months on a screen narrower than 768px, a panel of months side by side from there.
The calendar and the guests panel of the ready form open in the same place as those of a form of your own: in [data-pms-booking-overlay], an element of ours at the end of <body>. A ::part() rule written once on that element styles them for both — see How a part rule works.
With your own HTML
Recommended. Write the form in your own HTML and CSS. The script adds only what a browser cannot do: a calendar with prices, minimum stays and closed days, and a guests panel that asks the age of each child.
Your form, our calendar and guests panel
Put data-pms-dates and data-pms-guests on buttons of your own inside a form. They open our calendar and our guests panel, and what the guest picks is written into the form’s own fields — so the form still submits as a plain GET to your booking page.
Live preview on a sample hotel — invented rooms and prices, placeholder pictures. Open in a new tab
The live preview runs only when these docs are opened on a developer's own machine.
<form class="stay-search" method="get" action="/booking"> <button type="button" class="stay-field" data-pms-dates> <small>Check-in</small> <span data-pms-text="checkIn">Add date</span> </button> <button type="button" class="stay-field" data-pms-dates="check-out"> <small>Check-out</small> <span data-pms-text="checkOut">Add date</span> </button> <button type="button" class="stay-field" data-pms-guests> <small>Guests</small> <span data-pms-text="guests">2 adults</span> </button> <button class="stay-go">Search</button></form>.stay-search { display: flex; gap: 1px; border: 1px solid #d9cfb8; background: #d9cfb8;}.stay-field { flex: 1; padding: 14px 18px; border: 0; background: #fff; font: inherit; text-align: left; cursor: pointer;}.stay-field small { display: block; font-size: 11px; letter-spacing: 0.08em; text-transform: uppercase; color: #6b6f6a;}.stay-go { padding: 0 28px; border: 0; background: #1d3b36; color: #fff; font: inherit; cursor: pointer;}@media (max-width: 640px) { .stay-search { flex-direction: column; } .stay-go { padding: 14px; }}| Attribute | Values | What it does |
|---|---|---|
data-pms-dates | no value | "check-out" | Opens our calendar when pressed. With the value check-out it opens on the check-out date. |
data-pms-guests | no value | Opens our guests panel under the element. |
data-pms-text | a search-form field | Prints what the guest picked, in the page's language. Must sit inside the form. |
name="check_in" | YYYY-MM-DD | The arrival date. Written by the script when the guest picks; added as a hidden field when your form has none by this name. |
name="check_out" | YYYY-MM-DD | The departure date. Written and added the same way. |
name="adults" | 1–20 | The number of adults. Your own field is read and written when you have one; else one is added hidden, starting at 2. |
name="child_ages" | ages 0–17, comma-separated | One age per child. Added hidden, and left out of the address while there are no children. |
data-pms-field | no value | Marks a hidden field the script added to your form. |
Inside the form data-pms-text prints what was picked, in the page's language. What you write inside stays until the guest picks.
| Field | What it prints |
|---|---|
checkIn | The arrival date: Dec 08, 2026 — or as data-format says. |
checkOut | The departure date, written the same way. |
nights | The length of the stay in words: 2 nights. |
guests | The whole party in words. |
adults | The adults in words. |
children | The children in words. |
checkInDay | The day of the month, with no leading zero: 8. |
checkInMonth | The month's name: December. |
checkInMonthShort | The month's short name: Dec. |
checkInWeekday | The weekday's name: Tuesday. |
checkInYear | The year: 2026. |
checkOutDay | The day of the month, with no leading zero: 8. |
checkOutMonth | The month's name: December. |
checkOutMonthShort | The month's short name: Dec. |
checkOutWeekday | The weekday's name: Tuesday. |
checkOutYear | The year: 2026. |
A search without both dates opens the calendar instead of leaving the page. A child without an age opens the guests panel: a child is priced by its real age. Your stylesheet restyles the calendar and the guests panel: see Styling.
The day set large
The date in pieces — day, month, short month, weekday, year — each its own value, so your CSS can set the day large. data-months="1" shows one month in the calendar instead of two, on screens from 768px.
Live preview on a sample hotel — invented rooms and prices, placeholder pictures. Open in a new tab
The live preview runs only when these docs are opened on a developer's own machine.
<form class="stay-search" method="get" action="/booking"> <button type="button" class="stay-field" data-pms-dates data-months="1"> <small>Arrival</small> <span class="stay-date"> <b data-pms-text="checkInDay">–</b> <span> <span data-pms-text="checkInMonthShort">Add</span> <span data-pms-text="checkInYear">dates</span><br> <span data-pms-text="checkInWeekday"></span> </span> </span> </button> <button type="button" class="stay-field" data-pms-dates="check-out" data-months="1"> <small>Departure</small> <span class="stay-date"> <b data-pms-text="checkOutDay">–</b> <span> <span data-pms-text="checkOutMonth">Add</span> <span data-pms-text="checkOutYear">dates</span><br> <span data-pms-text="checkOutWeekday"></span> </span> </span> </button> <button type="button" class="stay-field" data-pms-guests> <small>Guests</small> <span data-pms-text="guests">2 adults</span><br> <span data-pms-text="nights"></span> </button> <button class="stay-go">Search</button></form>.stay-date { display: flex; align-items: baseline; gap: 8px;}.stay-date b { font-size: 40px; font-weight: 400; line-height: 1.1;}| Attribute | Values | What it does |
|---|---|---|
data-pms-dates | no value | "check-out" | Opens our calendar when pressed. With the value check-out it opens on the check-out date. |
data-months | "1" | Shows one month in the calendar instead of two, on screens from 768px. Any other value: two. |
data-pms-text | a search-form field | Prints what the guest picked, in the page's language. Must sit inside the form. |
data-pms-guests | no value | Opens our guests panel under the element. |
Like every value of a search form, the pieces must sit inside the form. The day has no leading zero.
A whole date, written your way
data-format on a checkIn or checkOut value chooses how the date is written, in the page’s language. Inside the form, like every value of the form.
<p class="stay-line"> <span data-pms-text="checkIn" data-format="weekday">Pick your dates</span> <span data-pms-text="checkOut" data-format="long"></span></p>| Attribute | Values | What it does |
|---|---|---|
data-pms-text | a search-form field | Prints what the guest picked, in the page's language. Must sit inside the form. |
data-format | "long" | "short" | "numeric" | "weekday" | "iso" | The same five words for a checkIn or checkOut value of the form. Left out: Dec 08, 2026. |
In English: long — 8 December; short — 8 Dec; weekday — Tuesday 8 December (no comma); numeric — 08/12/2026; iso — 2026-12-08. In Bulgarian: 8 декември; 8 дек; вторник, 8 декември; 08.12.2026 г.; 2026-12-08. numeric is the language’s own form, so it differs between the two. Without data-format, or with another word, the date is written as before: Dec 08, 2026. That is the default of a search form only; a room’s date in a template is YYYY-MM-DD by default — the one statement of both is under Field names.
State hooks for your CSS
The script sets these attributes on your page, your form and your values, and removes them when they stop being true. It never adds, removes or reorders an element of yours.
/* room for the cards is kept until the script has looked at the page: nothing jumps */html:not([data-pms-ready]) .rooms { min-height: 420px;}/* a value still in your own words is quieter than a live one */[data-pms-text]:not([data-pms-filled]) { color: #9b9484;}/* the button whose calendar or guests panel is open */.stay-search[data-pms-open="dates"] [data-pms-dates],.stay-search[data-pms-open="guests"] [data-pms-guests] { background: #f1e8d4;}/* Search wakes up once both dates are in */.stay-search:not([data-pms-has-dates]) .stay-go { background: #8fa5a9;}/* a one-night stay is worth a nudge */.stay-search[data-pms-nights="1"]::after { content: "Stay a second night — breakfast is on us.";}| Attribute | Values | What it does |
|---|---|---|
data-pms-ready | no value | Set once, when the script has bound the page for the first time. Never removed. |
data-pms-filled | no value | Present while a value the script wrote stands in the element; never while your own text does. It is removed again when your own words come back. |
data-pms-open | "dates" | "guests" | Which picker is open. Absent while none is. |
data-pms-has-dates | no value | Present while both dates are set and check-out is after check-in. |
data-pms-nights | the number of nights | The number of nights, while both dates are set. |
aria-expanded | "true" | "false" | true while that button's calendar or guests panel is open. |
data-pms-text | a search-form field | Prints what the guest picked, in the page's language. Must sit inside the form. |
data-pms-dates | no value | "check-out" | Opens our calendar when pressed. With the value check-out it opens on the check-out date. |
data-pms-guests | no value | Opens our guests panel under the element. |
Events on the form
Every change of the dates or the party fires pms-booking-search on the form; a calendar or guests panel opening and closing fires pms-booking-open and pms-booking-close. All three bubble, so one listener on document serves every form on the page. The ready search form fires the same three on its box.
const form = document.querySelector('.stay-search');
form.addEventListener('pms-booking-search', (event) => { const { checkIn, checkOut, nights, adults, childAges } = event.detail; // checkIn / checkOut: 'YYYY-MM-DD' or null · nights: 0 until both dates are set // childAges: one entry per child, null while the guest has not said the age});
form.addEventListener('pms-booking-open', (event) => { // event.detail.picker: 'dates' or 'guests'});form.addEventListener('pms-booking-close', (event) => {});From JavaScript
Open the calendar or the guests panel, read what the form holds, or set it — for an offer button that fills in its dates, say.
function whenBookingReady(run) { if (window.pmsBooking) run(window.pmsBooking); else window.addEventListener('pms-booking-ready', () => run(window.pmsBooking), { once: true, });}
whenBookingReady((booking) => { document.querySelector('#offer-december').addEventListener('click', () => { // both dates together: a date that would break their order is ignored booking.setSearch({ checkIn: '2026-12-08', checkOut: '2026-12-11', adults: 2, childAges: [6] }); booking.openDates(); });
const search = booking.getSearch(); // null while no form of yours is bound});With no form named, the first bound form of the page is used; a page with none uses its first ready search form. On a page with neither every call does nothing and getSearch() answers null.
setSearch() checks the shape of what you pass and nothing else: a date is a date, check-out is after check-in, the party is within its bounds. It does not ask whether the property can sell those dates — a closed day or a minimum stay is not checked here; the guest learns it in the calendar or in the room list. It returns nothing: a call it ignores whole looks the same as one it applied, except that no pms-booking-search follows.
A plain form
No attribute and no script of ours: a GET form to your booking page with these field names lands in the booking window already searched. A browser’s own date field shows no prices and no closed days.
<form class="stay-search" method="get" action="/booking"> <label>Check-in <input type="date" name="check_in" required></label> <label>Check-out <input type="date" name="check_out" required></label> <label>Adults <input type="number" name="adults" value="2" min="1" max="20"></label> <button>Search</button></form>| Attribute | Values | What it does |
|---|---|---|
name="check_in" | YYYY-MM-DD | The arrival date. Written by the script when the guest picks; added as a hidden field when your form has none by this name. |
name="check_out" | YYYY-MM-DD | The departure date. Written and added the same way. |
name="adults" | 1–20 | The number of adults. Your own field is read and written when you have one; else one is added hidden, starting at 2. |
name="child_ages" | ages 0–17, comma-separated | One age per child. Added hidden, and left out of the address while there are no children. |
For children add a field named child_ages with their ages, comma-separated: 4,9.
Every attribute, method and variable: Attributes · JavaScript · Styling.