All components · Category: Banners and notices
Inline notices
Information, success and warning notices whose icons draw themselves.
Notices for information, success and warning, each with an icon that draws itself, a heading and a message, and an optional close button. The kind is also said in words, so it never depends on color alone.
01
Try it
Props
Generated from the component's manifest and the values above.
index.html
<notice-inline locale="en"></notice-inline>
<script>
const element = document.querySelector("notice-inline");
element.addEventListener("notice-inline: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("notice-inline");
element.setAttribute("locale", "en");
element.addEventListener("notice-inline:dismissed", (event) => {
console.log(event.detail);
});
document.body.append(element);
- Add the site's Taggor script once; the component appears when it loads.
NoticeInline.tsx
import { useEffect, useRef } from "react";
export function NoticeInline() {
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("notice-inline:dismissed", onDismissed);
return () => {
element.removeEventListener("notice-inline:dismissed", onDismissed);
};
}, []);
return <notice-inline 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.
NoticeInline.tsx
import { useEffect, useRef } from "react";
export function NoticeInline() {
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("notice-inline:dismissed", onDismissed);
return () => {
element.removeEventListener("notice-inline:dismissed", onDismissed);
};
}, []);
return <notice-inline 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/NoticeInline.vue
<script setup lang="ts">
function onDismissed(event: Event) {
console.log((event as CustomEvent).detail);
}
</script>
<template>
<notice-inline locale="en" @notice-inline: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 === "notice-inline",
},
},
}),
],
});
- 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/notice-inline.component.ts
import { afterNextRender, Component, CUSTOM_ELEMENTS_SCHEMA, DestroyRef, ElementRef, inject } from "@angular/core";
@Component({
selector: "app-notice-inline",
schemas: [CUSTOM_ELEMENTS_SCHEMA],
template: `
<notice-inline locale="en"></notice-inline>
`,
})
export class NoticeInlineComponent {
constructor() {
const host = inject<ElementRef<HTMLElement>>(ElementRef);
const element = () => host.nativeElement.querySelector("notice-inline");
const onDismissed = (event: Event) => {
console.log((event as CustomEvent).detail);
};
afterNextRender(() => element()?.addEventListener("notice-inline:dismissed", onDismissed));
inject(DestroyRef).onDestroy(() => element()?.removeEventListener("notice-inline: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>
<notice-inline locale="en" onnotice-inline:dismissed={onDismissed}></notice-inline>
- 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
notice-inline {
--ni-radius: 16px;
}02
Props
| Prop | Type | Default | What it does |
|---|---|---|---|
| notices | list | none | The notices: a kind, a heading and a message each. Empty shows three samples. |
| hideClose | boolean | false | Removes the close buttons. |
| 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 |
|---|---|
| dismissed | A notice was closed. |
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 "Inline notices" (notice-inline): Information, success and warning notices whose icons draw themselves.
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
- Toast stack<toast-stack>
- Announcement bar<announcement-bar>
- Success check<success-check>