All components · Category: Depth and layers
Layers in depth
A stack of layers that separates, with a button to stack it back.
A stack of planes seen in depth that separates into its layers and stacks back with a button. The layer names are a real list beside it, and reduced motion changes the spacing with no movement.
01
Try it
Props
Generated from the component's manifest and the values above.
index.html
<layers-depth locale="en"></layers-depth>
<script>
const element = document.querySelector("layers-depth");
element.addEventListener("layers-depth:toggle", (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("layers-depth");
element.setAttribute("locale", "en");
element.addEventListener("layers-depth:toggle", (event) => {
console.log(event.detail);
});
document.body.append(element);
- Add the site's Taggor script once; the component appears when it loads.
LayersDepth.tsx
import { useEffect, useRef } from "react";
export function LayersDepth() {
const ref = useRef<HTMLElement>(null);
useEffect(() => {
const element = ref.current;
if (!element) return;
const onToggle = (event: Event) => {
console.log((event as CustomEvent).detail);
};
element.addEventListener("layers-depth:toggle", onToggle);
return () => {
element.removeEventListener("layers-depth:toggle", onToggle);
};
}, []);
return <layers-depth 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.
LayersDepth.tsx
import { useEffect, useRef } from "react";
export function LayersDepth() {
const ref = useRef<HTMLElement>(null);
useEffect(() => {
const element = ref.current;
if (!element) return;
const onToggle = (event: Event) => {
console.log((event as CustomEvent).detail);
};
element.addEventListener("layers-depth:toggle", onToggle);
return () => {
element.removeEventListener("layers-depth:toggle", onToggle);
};
}, []);
return <layers-depth 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/LayersDepth.vue
<script setup lang="ts">
function onToggle(event: Event) {
console.log((event as CustomEvent).detail);
}
</script>
<template>
<layers-depth locale="en" @layers-depth:toggle="onToggle" />
</template>
vite.config.ts
import vue from "@vitejs/plugin-vue";
import { defineConfig } from "vite";
export default defineConfig({
plugins: [
vue({
template: {
compilerOptions: {
isCustomElement: (tag) => tag === "layers-depth",
},
},
}),
],
});
- 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/layers-depth.component.ts
import { afterNextRender, Component, CUSTOM_ELEMENTS_SCHEMA, DestroyRef, ElementRef, inject } from "@angular/core";
@Component({
selector: "app-layers-depth",
schemas: [CUSTOM_ELEMENTS_SCHEMA],
template: `
<layers-depth locale="en"></layers-depth>
`,
})
export class LayersDepthComponent {
constructor() {
const host = inject<ElementRef<HTMLElement>>(ElementRef);
const element = () => host.nativeElement.querySelector("layers-depth");
const onToggle = (event: Event) => {
console.log((event as CustomEvent).detail);
};
afterNextRender(() => element()?.addEventListener("layers-depth:toggle", onToggle));
inject(DestroyRef).onDestroy(() => element()?.removeEventListener("layers-depth:toggle", onToggle));
}
}
- 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 onToggle(event) {
console.log(event.detail);
}
</script>
<layers-depth locale="en" onlayers-depth:toggle={onToggle}></layers-depth>
- 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
layers-depth {
--ld-radius: 12px;
}02
Props
| Prop | Type | Default | What it does |
|---|---|---|---|
| layers | list | none | The layer names, top first (3 to 6). |
| stacked | boolean | false | Starts stacked instead of separated. |
| startColor | color | #6366f1 | Colour of the top layer (hex). |
| endColor | color | #06b6d4 | Colour of the bottom layer (hex). |
| 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 |
|---|---|
| toggle | The stack was separated or stacked. |
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 "Layers in depth" (layers-depth): A stack of layers that separates, with a button to stack it back.
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
- Device mockup<device-mockup>
- Cube rotator<cube-rotator>