Embeddable web components
@ulams/ui ships three learner widgets as plain custom elements. They need no framework, render
in a shadow root so a host page’s CSS cannot break them, and read their data with @ulams/sdk.
| Element | Shows | Needs a learner token |
|---|---|---|
<ulams-catalogue limit="6"> |
The published courses (title, summary, level, duration), 1 to 24 of them | no |
<ulams-my-courses> |
The learner’s courses with a progress bar and a Start, Continue or Review link | yes |
<ulams-continue> |
One card: the course in progress (else the first unfinished one) and a link to its next topic | yes |
The quiz, H5P, video and progress elements in front/ui/src/elements are part of the lesson
player and only work inside the reference frontend. The certificate badge is described
below; so is the course tutor (the course tutor).
Use them
Section titled “Use them”Inside the reference frontend, add the element to a page. It calls the page’s own /bff, so the
learner’s httpOnly session cookie is used and no token is exposed:
<ulams-continue></ulams-continue>On another site, import the module once and point the element at the tenant API:
<script type="module"> import "@ulams/ui/elements/widgets.ts"; // through your bundler</script><ulams-catalogue api-url="https://acme.ulams.app" limit="4" course-href="https://learn.acme.example/courses/{course}"></ulams-catalogue><ulams-my-courses api-url="https://acme.ulams.app" token="LEARNER_TOKEN"></ulams-my-courses>| Attribute | Meaning | Default |
|---|---|---|
api-url |
Tenant API origin; without it the element uses /bff |
none |
token |
The learner’s API token (a token can never do more than its owner) | none |
limit |
Catalogue only: number of courses | 6 |
course-href |
Course link template, {course} is replaced |
/courses/{course} |
learn-href |
Lesson link template, {course} and {topic} are replaced |
/learn/{course}/{topic} |
Behaviour
Section titled “Behaviour”- Loading, empty and error states are announced (
role="status"androle="alert"); the error has a “Try again” link. Changing an attribute reloads the widget. - Text from the API is set with
textContent, never as HTML. - Links meet the 24 px target size (buttons are 44 px), show a 3 px focus ring, and progress bars
carry
role="progressbar"with a name and value. - Theme variables (
--ulams-color-*) pass through the shadow root; defaults give at least 4.5:1 contrast on a white page.
Tests: front/ui/tests/widgets.test.ts (rendering, attributes, errors, XSS, axe).
The course tutor
Section titled “The course tutor”<ulams-tutor> is a launcher button, “Ask the course tutor”, that opens a panel where a learner asks
questions and gets answers from the course only. Every answer is labelled “AI tutor · answers only
from this course” and links to the lessons it comes from. The panel keeps the learner’s earlier
conversations of the course (they can reopen or delete them; they are removed automatically after
the retention period) and shows how many questions are left today. While a quiz attempt is open it
says so and explains concepts only.
When the tenant allows streaming (streaming in the status call), the answer appears while it is
written. The text is a draft: it is marked busy and is not read out by screen readers, and the checked
answer with its citations replaces it and is announced once. With reduced motion the draft grows by
sentence. A reload mid-answer picks the answer up again, and without streaming the same panel uses the plain
request. See Course tutor settings.
<script type="module"> import "@ulams/ui/elements/tutor.ts"; // through your bundler</script><ulams-tutor course-id="5" topic-id="12" api-url="https://acme.ulams.app" token="LEARNER_TOKEN" learn-href="https://learn.acme.example/learn/{course}/{topic}"></ulams-tutor>| Attribute | Meaning | Default |
|---|---|---|
course-id |
The course the tutor answers from (required) | none |
topic-id |
The lesson that is open; its content is added to the search | none |
api-url, token |
As for the other widgets | /bff |
learn-href |
Link template of the citations | /learn/{course}/{topic} |
lang |
Interface language: en, pl or zh |
the page language |
The element asks GET /api/tutor/courses/{course}/status first and stays hidden when the tutor or AI
is switched off for the tenant, or the learner may not attend the course. The panel script
(about 17 KB gzipped) loads the first time the launcher is used. On a screen 720 px wide or more the
panel is a side sheet and the lesson stays readable; on a phone it is a full-screen dialog. Esc and
the close button return focus to the launcher. Answers are rendered from Markdown with raw HTML,
images and unsafe links removed.
Tests: front/ui/tests/tutor-element.test.ts and front/web/tests/a11y/tutor.a11y.spec.ts (axe,
keyboard, layout).
The certificate badge
Section titled “The certificate badge”<ulams-certificate-badge> shows whether a certificate is valid, for whom and until when. It asks
the public verification endpoint (GET /api/certificates/verify/{id}), so it needs no token and
works on any page: a learner pastes it on a personal site or a profile. The status is written out
(“Valid”, “Expired”, “Revoked on 1 September 2026”), never colour alone, and the badge links to the
verification page of the academy.
The account page “My training” has a Copy badge code button next to every certificate that copies the snippet with the certificate id filled in:
<script type="module" src="https://acme.ulams.app/embed/ulams-certificate-badge.js"></script><ulams-certificate-badge certificate-id="b3f1c2d4-1111-4222-8333-444455556666" api-url="https://acme.ulams.app" verify-href="https://acme.ulams.app/certificates/verify/{id}"></ulams-certificate-badge>| Attribute | Meaning | Default |
|---|---|---|
certificate-id |
The public certificate id (required) | none |
api-url |
Tenant API origin (required outside the API’s own origin) | none |
verify-href |
Link template, {id} is replaced; relative and http(s) only |
/certificates/verify/{id} |
lang |
Interface language: en, pl or zh |
the page language |
The holder name is shown when the verification endpoint returns it (it does today). A bundler can
import @ulams/ui/elements/certificate-badge.ts (or widgets.ts, which registers all widgets)
instead of the script tag. Unknown ids, a missing id and an unreachable API each get their own
announced message, and the error has a “Try again” link.
Tests: front/ui/tests/certificate-badge.test.ts (states, XSS, languages, axe) and
front/web/tests/a11y/training.a11y.spec.ts (the badge on a plain page).