Taggor

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

<booking-picker>
View

Props

Accent
Corners
booking-picker: Pick a day and a time slot, then ask for the booking. A picture of the real component, drawn from its own code. The controls change the picture and the code beside it; nothing here is sent or stored.

Generated from the component's manifest and the values above.

Code for

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 publish

The CSS variables the component exposes, set the way a customer's page would.

styles.css

booking-picker {
  --bp-radius: 10px;
}

02

Props

Props of the component, read from its manifest
PropTypeDefaultWhat it does
headlinestringnoneReplaces the default heading.
accentcolornoneAccent color of the chosen day and time and the button.
weekdayslist["mon","tue","wed","thu","fri"]The weekdays that take bookings.
windowslist[{"start":"09:00","end":"12:00"},{"start":"13:0…The periods of the day that take bookings, `HH:MM` to `HH:MM`.
slotMinutesnumber 5 to 24030–
daysAheadnumber 1 to 6014How many days, counted from the first, are offered.
startDatedatenoneThe first day offered; today when absent.
blockedDateslistnoneDays with nothing offered, as `YYYY-MM-DD`.
busylistnoneTimes already taken, as `YYYY-MM-DDTHH:MM`; the page keeps it up to date.
hour12auto | 12h | 24hauto–
timezoneNotestringnoneA note under the times, such as the zone they are in.
privacyPolicyurlnoneLink to the site's privacy policy.
localept-BR | enen–

Prop names and descriptions are the component's own, in English, as its author wrote them.

03

Events

Events of the component, read from its manifest
EventWhen it fires
selectedThe visitor picked a time.
bookedThe 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