Skip to content

Styling and events

The widgets are web components with their own styles, so the CSS of your website doesn’t break them. This page shows how you can still change how they look, and how to react to what guests do in them.

By default, widgets use the primary color you’ve set for your Booking Engine in Camping.care, and the font of your page. Override them with these CSS variables:

Variable Description
--cc-primary Color of buttons, selected dates and links.
--cc-on-primary Text color on the primary color. Defaults to white.
--cc-font-family Font of the widget.
booking-engine {
--cc-primary: #2e7d32;
--cc-on-primary: #fff;
--cc-font-family: "Open Sans", sans-serif;
}

For more control, use the widget’s own element instead of <booking-engine> and style its parts with ::part():

widget= Element
search-and-book <cc-search-and-book>
filter <cc-accommodations>
map <cc-map>
grid <cc-price-grid>
my-reservation <cc-my-reservation>

The element takes the same attributes as <booking-engine>, without widget. Write the public key as public-key here, and the reservation ID of My reservation as reservation-id.

<cc-accommodations
administration="{Your administration slug}"
public-key="{Your public key}"
></cc-accommodations>
<style>
cc-accommodations::part(card) { border-radius: 0; }
cc-accommodations::part(button) { text-transform: uppercase; }
</style>

These are the parts you can style:

Part Widgets
bar The search bar: Search and book. On phones, the collapsed summary.
button The main button: all widgets.
alert Error and info messages: all widgets.
list, card, price The list, an accommodation and its price: Accommodation filter.
map, marker, marker-free, marker-taken The map and its places: Interactive map.
grid The prices: Pricing grid.
dialog The summary that opens on a price or place: Pricing grid, Interactive map.
form, label, input, hint The email form: My reservation.

Widgets send events when guests search or book. They bubble up from the widget, so you can listen on <booking-engine>, the widget’s own element or document. Each event has its data in event.detail.

Event Widget event.detail
search Search and book arrival, departure, guests, accommodation, category, url
search-change Search and book arrival, departure, guests, accommodation, category
book Accommodation filter, Pricing grid arrival, departure, nights, total, accommodation, guests, url
view-accommodation Accommodation filter accommodation, url
select-place Interactive map accommodation, place, placeName, arrival, departure, guests, url
reservation-email-sent My reservation none

Dates are YYYY-MM-DD. guests is a list of {id, count} per age table, accommodation and place are IDs, and url is the Booking Engine page the widget is about to open.

document.addEventListener('book', (event) => {
const {accommodation, total, nights} = event.detail;
gtag('event', 'begin_checkout', {value: total, items: [{item_id: accommodation, quantity: nights}]});
});

The search, book, view-accommodation and select-place events are cancelable. Call event.preventDefault() and the widget doesn’t open the Booking Engine, so you can do it yourself, for example in a new tab:

document.addEventListener('search', (event) => {
event.preventDefault();
window.open(event.detail.url, '_blank');
});