Taggor

All components · Category: Banners and notices

Announcement bar

A bar that slides away when the page scrolls, and can be dismissed.

A gradient bar with a message and a link. It watches its own sample box or your page, slides away with a CSS transform so nothing jumps, and leaves a slim tab to bring it back. Dismissing it is kept in memory only: no cookie, no storage.

01

Try it

<announcement-bar>
View

Props

Corners
announcement-bar: A bar that slides away when the page scrolls, and can be dismissed. 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

<announcement-bar href="https://example.com/program" locale="en"></announcement-bar>

<script>
  const element = document.querySelector("announcement-bar");
  element.addEventListener("announcement-bar:dismissed", (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("announcement-bar");
element.setAttribute("href", "https://example.com/program");
element.setAttribute("locale", "en");
element.addEventListener("announcement-bar:dismissed", (event) => {
  console.log(event.detail);
});
document.body.append(element);
  • Add the site's Taggor script once; the component appears when it loads.

AnnouncementBar.tsx

import { useEffect, useRef } from "react";

export function AnnouncementBar() {
  const ref = useRef<HTMLElement>(null);

  useEffect(() => {
    const element = ref.current;
    if (!element) return;
    const onDismissed = (event: Event) => {
      console.log((event as CustomEvent).detail);
    };
    element.addEventListener("announcement-bar:dismissed", onDismissed);
    return () => {
      element.removeEventListener("announcement-bar:dismissed", onDismissed);
    };
  }, []);

  return <announcement-bar
      ref={ref}
      href="https://example.com/program"
      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.

AnnouncementBar.tsx

import { useEffect, useRef } from "react";

export function AnnouncementBar() {
  const ref = useRef<HTMLElement>(null);

  useEffect(() => {
    const element = ref.current;
    if (!element) return;
    const onDismissed = (event: Event) => {
      console.log((event as CustomEvent).detail);
    };
    element.addEventListener("announcement-bar:dismissed", onDismissed);
    return () => {
      element.removeEventListener("announcement-bar:dismissed", onDismissed);
    };
  }, []);

  return <announcement-bar
      ref={ref}
      href="https://example.com/program"
      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/AnnouncementBar.vue

<script setup lang="ts">
function onDismissed(event: Event) {
  console.log((event as CustomEvent).detail);
}
</script>

<template>
  <announcement-bar
    href="https://example.com/program"
    locale="en"
    @announcement-bar:dismissed="onDismissed"
  />
</template>

vite.config.ts

import vue from "@vitejs/plugin-vue";
import { defineConfig } from "vite";

export default defineConfig({
  plugins: [
    vue({
      template: {
        compilerOptions: {
          isCustomElement: (tag) => tag === "announcement-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/announcement-bar.component.ts

import { afterNextRender, Component, CUSTOM_ELEMENTS_SCHEMA, DestroyRef, ElementRef, inject } from "@angular/core";

@Component({
  selector: "app-announcement-bar",
  schemas: [CUSTOM_ELEMENTS_SCHEMA],
  template: `
    <announcement-bar href="https://example.com/program" locale="en"></announcement-bar>
  `,
})
export class AnnouncementBarComponent {
  constructor() {
    const host = inject<ElementRef<HTMLElement>>(ElementRef);
    const element = () => host.nativeElement.querySelector("announcement-bar");
    const onDismissed = (event: Event) => {
      console.log((event as CustomEvent).detail);
    };
    afterNextRender(() => element()?.addEventListener("announcement-bar:dismissed", onDismissed));
    inject(DestroyRef).onDestroy(() => element()?.removeEventListener("announcement-bar:dismissed", onDismissed));
  }
}
  • 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 onDismissed(event) {
    console.log(event.detail);
  }
</script>

<announcement-bar
  href="https://example.com/program"
  locale="en"
  onannouncement-bar:dismissed={onDismissed}
></announcement-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 publish

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

styles.css

announcement-bar {
  --ab-radius: 16px;
}

02

Props

Props of the component, read from its manifest
PropTypeDefaultWhat it does
messagestringnoneReplaces the announcement text.
ctastringnoneReplaces the link text.
hrefurlnoneWhere the link goes; without it there is no link.
watchbox | windowboxbox scrolls a sample page under the bar; window follows the host page.
hideSamplebooleanfalseHides the Sample content mark.
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
dismissedThe visitor closed the bar.

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 "Announcement bar" (announcement-bar): A bar that slides away when the page scrolls, and can be dismissed. 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