All components · Category: Forms
Booking picker
Pick a day and a time slot, then ask for the booking.
Shows the days and time windows your site offers, hides the busy ones and asks for a name and an e-mail. It sends a request, not a confirmation: your site answers.
01
Try it
Props
Generated from the component's manifest and the values above.
index.html
<booking-picker locale="en"></booking-picker>
<script>
const element = document.querySelector("booking-picker");
element.addEventListener("booking-picker:selected", (event) => {
console.log(event.detail);
});
element.addEventListener("booking-picker:booked", (event) => {
console.log(event.detail);
});
</script>
- Add the site's Taggor script once; the component appears when it loads.
taggor-component.js
const element = document.createElement("booking-picker");
element.setAttribute("locale", "en");
element.addEventListener("booking-picker:selected", (event) => {
console.log(event.detail);
});
element.addEventListener("booking-picker:booked", (event) => {
console.log(event.detail);
});
document.body.append(element);
- Add the site's Taggor script once; the component appears when it loads.
BookingPicker.tsx
import { useEffect, useRef } from "react";
export function BookingPicker() {
const ref = useRef<HTMLElement>(null);
useEffect(() => {
const element = ref.current;
if (!element) return;
const onSelected = (event: Event) => {
console.log((event as CustomEvent).detail);
};
element.addEventListener("booking-picker:selected", onSelected);
const onBooked = (event: Event) => {
console.log((event as CustomEvent).detail);
};
element.addEventListener("booking-picker:booked", onBooked);
return () => {
element.removeEventListener("booking-picker:selected", onSelected);
element.removeEventListener("booking-picker:booked", onBooked);
};
}, []);
return <booking-picker ref={ref} locale="en" />;
}
- Add the site's Taggor script once; the component appears when it loads.
- React 18 sends every prop of a custom element as a text attribute.
- The event is heard with addEventListener, inside an effect.
BookingPicker.tsx
import { useEffect, useRef } from "react";
export function BookingPicker() {
const ref = useRef<HTMLElement>(null);
useEffect(() => {
const element = ref.current;
if (!element) return;
const onSelected = (event: Event) => {
console.log((event as CustomEvent).detail);
};
element.addEventListener("booking-picker:selected", onSelected);
const onBooked = (event: Event) => {
console.log((event as CustomEvent).detail);
};
element.addEventListener("booking-picker:booked", onBooked);
return () => {
element.removeEventListener("booking-picker:selected", onSelected);
element.removeEventListener("booking-picker:booked", onBooked);
};
}, []);
return <booking-picker ref={ref} locale="en" />;
}
- Add the site's Taggor script once; the component appears when it loads.
- React 19 sets a property when the element already has it, an attribute otherwise.
- The event is heard with addEventListener, inside an effect.
src/BookingPicker.vue
<script setup lang="ts">
function onSelected(event: Event) {
console.log((event as CustomEvent).detail);
}
function onBooked(event: Event) {
console.log((event as CustomEvent).detail);
}
</script>
<template>
<booking-picker
locale="en"
@booking-picker:selected="onSelected"
@booking-picker:booked="onBooked"
/>
</template>
vite.config.ts
import vue from "@vitejs/plugin-vue";
import { defineConfig } from "vite";
export default defineConfig({
plugins: [
vue({
template: {
compilerOptions: {
isCustomElement: (tag) => tag === "booking-picker",
},
},
}),
],
});
- Add the site's Taggor script once; the component appears when it loads.
- vite.config.ts tells Vue that this tag is not a Vue component.
src/app/booking-picker.component.ts
import { afterNextRender, Component, CUSTOM_ELEMENTS_SCHEMA, DestroyRef, ElementRef, inject } from "@angular/core";
@Component({
selector: "app-booking-picker",
schemas: [CUSTOM_ELEMENTS_SCHEMA],
template: `
<booking-picker locale="en"></booking-picker>
`,
})
export class BookingPickerComponent {
constructor() {
const host = inject<ElementRef<HTMLElement>>(ElementRef);
const element = () => host.nativeElement.querySelector("booking-picker");
const onSelected = (event: Event) => {
console.log((event as CustomEvent).detail);
};
afterNextRender(() => element()?.addEventListener("booking-picker:selected", onSelected));
inject(DestroyRef).onDestroy(() => element()?.removeEventListener("booking-picker:selected", onSelected));
const onBooked = (event: Event) => {
console.log((event as CustomEvent).detail);
};
afterNextRender(() => element()?.addEventListener("booking-picker:booked", onBooked));
inject(DestroyRef).onDestroy(() => element()?.removeEventListener("booking-picker:booked", onBooked));
}
}
- Add the site's Taggor script once; the component appears when it loads.
- The component declares CUSTOM_ELEMENTS_SCHEMA.
- The event is heard with addEventListener, inside an effect.
src/TaggorComponent.svelte
<script>
function onSelected(event) {
console.log(event.detail);
}
function onBooked(event) {
console.log(event.detail);
}
</script>
<booking-picker
locale="en"
onbooking-picker:selected={onSelected}
onbooking-picker:booked={onBooked}
></booking-picker>
- Add the site's Taggor script once; the component appears when it loads.
How an agent gets a component like this onto a site:
taggor checktaggor publishThe CSS variables the component exposes, set the way a customer's page would.
styles.css
booking-picker {
--bp-radius: 10px;
}02
Props
| Prop | Type | Default | What it does |
|---|---|---|---|
| headline | string | none | Replaces the default heading. |
| accent | color | none | Accent color of the chosen day and time and the button. |
| weekdays | list | ["mon","tue","wed","thu","fri"] | The weekdays that take bookings. |
| windows | list | [{"start":"09:00","end":"12:00"},{"start":"13:0… | The periods of the day that take bookings, `HH:MM` to `HH:MM`. |
| slotMinutes | number 5 to 240 | 30 | – |
| daysAhead | number 1 to 60 | 14 | How many days, counted from the first, are offered. |
| startDate | date | none | The first day offered; today when absent. |
| blockedDates | list | none | Days with nothing offered, as `YYYY-MM-DD`. |
| busy | list | none | Times already taken, as `YYYY-MM-DDTHH:MM`; the page keeps it up to date. |
| hour12 | auto | 12h | 24h | auto | – |
| timezoneNote | string | none | A note under the times, such as the zone they are in. |
| privacyPolicy | url | none | Link to the site's privacy policy. |
| locale | pt-BR | en | en | – |
Prop names and descriptions are the component's own, in English, as its author wrote them.
03
Events
| Event | When it fires |
|---|---|
| selected | The visitor picked a time. |
| booked | The booking request was accepted by Taggor. |
04
Build one with your agent
Paste this into your agent. It asks you before it signs in, pays or goes further than checking and publishing.
Build me a Taggor component like "Booking picker" (booking-picker): Pick a day and a time slot, then ask for the booking.
Fetch https://taggor.dev/agent-setup/prompt.md and follow its instructions to set me up for Taggor. Ask me before you sign in, create an account, accept terms, pay for anything or type a secret.
Check it with `taggor check` and publish it with `taggor publish`, and stop there.
Do not promote it to production, attach it to a site, roll back anything or use --yes, --force or --force-drop-invalid unless I ask for exactly that in this conversation.
05
Related components
- Lead form<contact-form>
- Launch countdown<launch-countdown>
- Quote wizard<quote-wizard>