docs / getting started / examples
Working examples
Compare real integrations and copy a focused starting point.
##Explore complete pages
- The live playground combines automatic scanning, annotations, four tools, tokens, controls, and replay.
- The portfolio example demonstrates a darker host design with the same overlay and shared Swarm Troopers header.
Use Replay to create a fresh instance. Try Off, reload the page to check the saved preference, and inspect a heading after completion. The host page remains its own design; Swarm Troopers does not require a component library.
##Watch the four tools
This compact example uses the actual built library, not a recording. It can complete inside its frame; if reduced motion is enabled, the finished content appears without the animation.
Open the tools example on its own.
##A small annotated starter
<main id="showcase">
<section data-swarmtroopers-section="An introduction">
<h1 data-swarmtroopers="type">Make room for good ideas.</h1>
<article data-swarmtroopers="frame">A thoughtfully framed card.</article>
<hr data-swarmtroopers="rule">
<ul data-swarmtroopers="repeat">
<li>One idea</li><li>Another idea</li><li>Something clicks</li>
</ul>
</section>
</main>
<script src="https://unpkg.com/swarmtroopers@0.4.0/dist/swarmtroopers.core.iife.js"
data-swarmtroopers-init='{"root":"#showcase","inspect":true,"controls":true}'></script>Add your normal typography, spacing, card surfaces, and list styling. The annotations choose tools; they do not replace the host design.
##Start on an intentional action
Manual mode collects and hides selected elements before starting. Keep the start button outside the root, avoid hiding essential content, and consider whether a static preview is a better initial state for your audience.
const swarmtroopers = create({
root: '#showcase',
auto: true,
trigger: 'manual',
});
document.querySelector('#start-demo').addEventListener('click', () => {
swarmtroopers.start();
}, { once: true });##Completion behavior
The completion celebration plays after a natural build with at least one spawned agent. finale: false disables it; finish() reveals content without playing it. A deliberate wheel, touch, click, or key dismisses it after its initial half-second. It clears automatically in under four seconds.
Try the compact completion example. This is a behavior reference, not a required section of your website.