Reference

JavaScript API

One global, LinkBio (aliased LB). Every method below is stable across components — the API does not vary by category.

Mounting

MethodReturnsDescription
LinkBio.mount(el, name?, props?)InstanceMounts one component. The name falls back to the element's data-lb.
LinkBio.mountAll(root?)Instance[]Mounts every unmounted [data-lb] in a root. Call it after injecting markup.
LinkBio.create(name, props)ElementBuilds a detached, mounted element for hosts that assemble their own DOM.
LinkBio.page(el, config)Instance[]Renders a whole page from one JSON document.
LinkBio.instance(el)Instance | nullThe instance mounted on an element.
LinkBio.destroyAll(root?)voidTears down every instance in a subtree.

Instance

MemberDescription
.elThe host element.
.propsResolved props, after defaults, JSON, attributes and arguments are merged.
.update(next)Merges props and re-renders in place, running teardown first.
.setState(state)Sets data-lb-state and aria-busy: default, loading, empty or error.
.destroy()Runs teardown callbacks, empties the element and releases the instance.

Events

Every event is a bubbling CustomEvent named lb:<type>, mirrored on a global bus. detail always carries component and instance.

EventFired byDetail
lb:readyEvery component, once mounted{ name, props }
lb:clickLinks, buttons, social icons, products{ href, label }
lb:submitNewsletter, waitlist, email capture, survey, comments{ value, fields }
lb:toggleDisclosures, accordions, theme toggle, bio{ open } or { theme }
lb:copyCopy link, code snippet, coupon, share{ value }
lb:selectPoll, rating, tabs, language switcher, palette, carousel{ value, index }
lb:dismissAnnouncement banner, alert, floating CTA{ id }
lb:errorAny component whose action failed{ message }

Configuration

The kit makes no network request at all. Brand marks are inline paths and both typefaces ship with the stylesheet, so a page works offline and on a first, cold visit alike.

Theme

Utilities

MethodDescription
LinkBio.h(tag, attrs, children)The DOM builder. Text is always assigned via textContent.
LinkBio.icon(name, opts)An inline SVG from the Phosphor vocabulary.
LinkBio.brandIcon(slug, opts)An inline brand mark inheriting currentColor. Falls back to a monogram, never to blank space.
LinkBio.platformTitle(slug)The correct display name for a platform — "Apple Podcasts", not "Applepodcasts".
LinkBio.util.safeUrl(url)Rejects javascript: and non-image data: URLs.
LinkBio.util.count(n)12800 → 12.8K. Display only; the exact value stays in the accessible name.
LinkBio.util.money(n, currency)Locale-aware currency formatting.
LinkBio.announce(message)Speaks through the kit's single polite live region.
LinkBio.schema(name)The JSON Schema for one component, generated from its prop table.
LinkBio.jsonLd(profile, links)A ProfilePage JSON-LD script element for SEO.

Writing your own component

Register with the same contract the built-ins use, and it gains config resolution, lifecycle, events, docs metadata and a JSON Schema for free.

Navigation

Start here

Foundations

Components

See it

On this page