Reference
JavaScript API
One global, LinkBio (aliased LB). Every method below is stable across components — the API does not vary by category.
Mounting
| Method | Returns | Description |
|---|---|---|
LinkBio.mount(el, name?, props?) | Instance | Mounts 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) | Element | Builds 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 | null | The instance mounted on an element. |
LinkBio.destroyAll(root?) | void | Tears down every instance in a subtree. |
Instance
| Member | Description |
|---|---|
.el | The host element. |
.props | Resolved 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.
| Event | Fired by | Detail |
|---|---|---|
lb:ready | Every component, once mounted | { name, props } |
lb:click | Links, buttons, social icons, products | { href, label } |
lb:submit | Newsletter, waitlist, email capture, survey, comments | { value, fields } |
lb:toggle | Disclosures, accordions, theme toggle, bio | { open } or { theme } |
lb:copy | Copy link, code snippet, coupon, share | { value } |
lb:select | Poll, rating, tabs, language switcher, palette, carousel | { value, index } |
lb:dismiss | Announcement banner, alert, floating CTA | { id } |
lb:error | Any 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
| Method | Description |
|---|---|
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.