Widgets display your PERSCOM organizational data on external websites. Each widget is an HTML snippet that renders a visual component such as a roster, calendar, or awards list.
Copy and paste the HTML snippet below into your website. Replace APIKEY with your API key and set the data-widget attribute to the widget ID you want to display.
A few widgets support the ability to provide an identifier to retrieve a specific resource. For example, you may want to display a specific form in your website. By providing the data-resource attribute, you can retrieve a specific form.Supported Widgets: Forms
Alpine.js provides a lightweight way to add dynamic behavior to your HTML. Use Alpine to conditionally configure widgets based on your page state.This example detects dark mode on the parent page and enables dark mode on the widget:
Navigate the widget to a different view by dispatching a browser event. The widget iframe listens for these events and updates its content accordingly.
Copy
document.addEventListener("DOMContentLoaded", () => { window.parent.postMessage({ type: 'widget:navigate', path: 'roster' // The widget ID. This will translate to the iframe URL being: https://api.perscom.io/v2/widgets/{path} }, '*')});