All components · Category: Pricing and counters
Free shipping bar
A progress bar with a truck toward the free-delivery line.
A bar that fills toward the total that earns free delivery, with a small truck riding its tip and the amount that is missing in words. The total is a prop and a slider lets a visitor try others. No countdown, no urgency tricks, no cart and nothing sent anywhere.
01
Try it
Props
Generated from the component's manifest and the values above.
index.html
<free-shipping-bar threshold="50" amount="32" locale="en"></free-shipping-bar>
<script>
const element = document.querySelector("free-shipping-bar");
element.addEventListener("free-shipping-bar:reached", (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("free-shipping-bar");
element.setAttribute("threshold", "50");
element.setAttribute("amount", "32");
element.setAttribute("locale", "en");
element.addEventListener("free-shipping-bar:reached", (event) => {
console.log(event.detail);
});
document.body.append(element);
- Add the site's Taggor script once; the component appears when it loads.
FreeShippingBar.tsx
import { useEffect, useRef } from "react";
export function FreeShippingBar() {
const ref = useRef<HTMLElement>(null);
useEffect(() => {
const element = ref.current;
if (!element) return;
const onReached = (event: Event) => {
console.log((event as CustomEvent).detail);
};
element.addEventListener("free-shipping-bar:reached", onReached);
return () => {
element.removeEventListener("free-shipping-bar:reached", onReached);
};
}, []);
return <free-shipping-bar ref={ref} threshold="50" amount="32" 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.
FreeShippingBar.tsx
import { useEffect, useRef } from "react";
export function FreeShippingBar() {
const ref = useRef<HTMLElement>(null);
useEffect(() => {
const element = ref.current;
if (!element) return;
const onReached = (event: Event) => {
console.log((event as CustomEvent).detail);
};
element.addEventListener("free-shipping-bar:reached", onReached);
return () => {
element.removeEventListener("free-shipping-bar:reached", onReached);
};
}, []);
return <free-shipping-bar ref={ref} threshold={50} amount={32} 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/FreeShippingBar.vue
<script setup lang="ts">
function onReached(event: Event) {
console.log((event as CustomEvent).detail);
}
</script>
<template>
<free-shipping-bar
:threshold.prop="50"
:amount.prop="32"
locale="en"
@free-shipping-bar:reached="onReached"
/>
</template>
vite.config.ts
import vue from "@vitejs/plugin-vue";
import { defineConfig } from "vite";
export default defineConfig({
plugins: [
vue({
template: {
compilerOptions: {
isCustomElement: (tag) => tag === "free-shipping-bar",
},
},
}),
],
});
- 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/free-shipping-bar.component.ts
import { afterNextRender, Component, CUSTOM_ELEMENTS_SCHEMA, DestroyRef, ElementRef, inject } from "@angular/core";
@Component({
selector: "app-free-shipping-bar",
schemas: [CUSTOM_ELEMENTS_SCHEMA],
template: `
<free-shipping-bar [threshold]="50" [amount]="32" locale="en"></free-shipping-bar>
`,
})
export class FreeShippingBarComponent {
constructor() {
const host = inject<ElementRef<HTMLElement>>(ElementRef);
const element = () => host.nativeElement.querySelector("free-shipping-bar");
const onReached = (event: Event) => {
console.log((event as CustomEvent).detail);
};
afterNextRender(() => element()?.addEventListener("free-shipping-bar:reached", onReached));
inject(DestroyRef).onDestroy(() => element()?.removeEventListener("free-shipping-bar:reached", onReached));
}
}
- 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 onReached(event) {
console.log(event.detail);
}
</script>
<free-shipping-bar
threshold={50}
amount={32}
locale="en"
onfree-shipping-bar:reached={onReached}
></free-shipping-bar>
- 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
free-shipping-bar {
--fs-radius: 16px;
}02
Props
| Prop | Type | Default | What it does |
|---|---|---|---|
| threshold | number 1 to 100000 | 50 | The total that earns free delivery. |
| amount | number 0 to 100000 | 32 | The cart total now. |
| currency | string | USD | ISO 4217 code of the amounts. |
| hideTry | boolean | false | Hides the slider that tries other totals. |
| 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 |
|---|---|
| reached | The total reached the threshold. |
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 "Free shipping bar" (free-shipping-bar): A progress bar with a truck toward the free-delivery line.
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
- Mini cart<mini-cart>
- Variant picker<variant-picker>
- Pricing toggle<pricing-toggle>