Skip to main content

Elements reference

Markdown

The ready-made parts as HTML elements, for any page: no React needed, nothing to build. Each draws on the rooms, calls and streams of the page (connect()), and does only what your server rules let the page user do (permissions).

They are optional. To draw any of them with your own components instead, use the API they are built on: your own interface shows it, element by element.

const rt = await connect( config );
await rt.callScreen(); // the call screen and ring, and the elements below but the streams
await rt.streamScreen(); // <live-stream> and <stream-studio>

rt.ui() loads the same script without the calls: who is in a room, the count, typing and the chat, with no call buttons and no ring. An element on the page before its script loads draws once it has.

ElementWhat it is
<call-button>a button that calls someone
<room-button>a button that joins a group call
<online-list>who is in a presence room, with call buttons
<online-count>how many are in a room
<typing-line>who is typing in a room
<chat-room>a conversation on a room, and with call, its call in it
<call-screen>where the call screen draws, with its templates
<call-spot>a place in the page for a call, in place of the window in the corner
<live-stream>a live stream, or one of its parts
<stream-studio>the studio of a live stream, for its host

Your own names​

The names are plain words, so your pages name nothing but your app. To put a name of your own before each one, give the elements a prefix:

const rt = await connect( { ...config, screen: { prefix: 'shop' } } );
<shop-call-button to="34" call="support:{pair}">Call Ann</shop-call-button>
<shop-chat-room room="chat:34:42"></shop-chat-room>
<shop-live-stream name="show:42"></shop-live-stream>
  • One prefix a page. The scripts read it as they load, so give it before the first callScreen(), ui() or streamScreen(). The React components take it from the same screen in RealtimeProvider options.
  • A name another script on the page already has stays with that script. Your console says which one and points to this setting: a prefix gives ours names no one else has.
  • Loading the script yourself: data-prefix="shop" on its <script> tag.
  • A prefix is lowercase letters and digits, starting with a letter, with hyphens between them: shop, my-shop.

<call-button>​

<call-button to="34" call="support:{pair}" type="video" name="Ann" avatar="https://…/ann.jpg">Call Ann</call-button>
Attribute
tothe user id to call
callthe name of the call, as your calls() rule allows it. {pair} is the page user and to, the smaller id first (text ids in text order), so either of the two calling names the same call. {me} is the page user, {id} is to
typevideo (the default) or audio
name, avatarwho is called, for the call window while it rings

Its content is the text of the button. The button is the part button: call-button::part(button) { … }.

<room-button>​

<room-button room="meeting:daily" type="video" title="Daily meeting">Join the meeting</room-button>
Attribute
roomthe name of the group call, as your groupCalls() rule allows it
typevideo (the default) or audio
titlethe title of the call window

Its content is the text of the button, the part button.

<online-list>​

<online-list room="shop" title="In the shop now" call="support:{pair}" type="video audio"></online-list>
Attribute
rooma presence room
titleabove the list, Online by default. Its number of people follows it
callthe name of a call to each of the others, {pair} as above, on the rows of those your calls() rule lets the user call. Without it, no call buttons
typethe call buttons on each row: video, audio, or both, video audio

Each row shows the name and picture your server gives the member (info, or your profile()), and an online dot. Template and part: online-row (customizing).

<online-count>​

<online-count room="product:42"></online-count>

How many are in a room that counts (count or presence), and nothing while it is empty.

<typing-line>​

<typing-line room="chat:34:42" event="typing"></typing-line>
Attribute
roomthe room
eventthe event a page sends while its user types, typing by default, { on: true } and { on: false }, which <chat-room> sends

<chat-room>​

<chat-room room="chat:34:42" messages="/api/chat/34/42/messages" placeholder="Write a message" reactions="👍 ❤️ 😂" max-length="2000"
style="height: 520px"></chat-room>
Attribute
roomthe room of the conversation, whose rule lets the page send message, typing, read and reaction
messagesyour route for the messages your server kept, asked with the page cookies. ?before=<id> asks for the page before that message. It answers { messages: [ { id, from, text, at, files, reactions } ], more }, oldest first, files where a message has any
placeholderthe words in the empty composer
reactionsthe reactions to pick from, emoji (👍 ❤️) or their code points (1f44d 2764), apart by spaces. Empty for none. 👍 ❤️ 😂 😮 😢 🙏 by default
max-lengththe most characters of a message
toin a chat between two, the other person: on the chat's top bar, with whether they are online
name, avatarthe name and picture of to, as your page has them: on the bar, on their messages and in their call. Without them, your directory's, which has a person only for a day after they were last online
callthe call of the conversation, shown in the chat while it is on. call alone is the call named as the room, which your calls() rule decides, and a value names another (date:{pair}). With to, the bar has a video and an audio call button
start-callvideo or audio: calls to as the chat opens, once, for a page that a Video button elsewhere links to, so the call starts in the chat
uploadyour route for files: with it, the composer has its paperclip, and takes files pasted or dropped on the chat. Each file goes to it as it is picked, POST with the page cookies, as a form of the file and the room, and it answers the file as your server keeps it: { id, url, name, type, size }, or an error status with { error: "…" }, whose words the file shows (files)
acceptthe files the picker offers, as an input's accept: image/*,.pdf. Every kind by default
max-file-sizethe largest file in bytes, refused before it goes up. Your route decides by default
max-filesthe most files in one message, 10 by default
file-hoststhe hosts your files are kept on beside your site's own, such as your storage's, apart by spaces. A file elsewhere is not shown, as anyone may write any address into a message of their own
Property
loadin place of messages: async ( before ) => ( { messages, more } ), for a route that needs headers of its own. before is null for the newest page, or the oldest message shown ({ id, at }). It may be set before the element is on the page
Event
senta message of this user the room took, { id, room, text, at, files } as its detail, files where it has any: for your server to keep it and tell the other person where no webhook reaches it (chat)

It fills the height the page gives it. With neither messages nor load, it shows what the room still keeps (5 minutes). What it sends (events from the page):

EventData
message{ text }, with an ack, and files, those your route took for it, where it has any
typing{ on }, volatile
read{ id }, the newest message seen, volatile
reaction{ id, key }, key empty to take it back, with an ack

Templates: message, empty-conversation. Parts: message, composer, empty-conversation, chat-header.

Its call: with call, the call shows beside the messages where the chat is 600px wide or more, and takes the whole chat where it is narrower, Show Chat putting the messages under it. Show Chat and Hide Chat are in the call controls. The call moves in as the page with the chat opens and goes on elsewhere as it closes, as in a <call-spot>, and the chat wins over a spot for every call. <CallScreen /> or rt.callScreen() runs it.

<chat-room room="chat:34:42" to="42" name="Ben" avatar="/photos/42.jpg" call messages="/api/chat/34/42/messages" style="height: 560px"></chat-room>

<call-screen>​

The call screen draws by itself, in an element of its own at the end of the page. Write <call-screen> on the page to give it templates of your own:

<call-screen>
<template slot="ring-card">
<div class="ring"><b data-field="name"></b> is calling
<button data-action="answer">Pick up</button> <button data-action="reject">Not now</button></div>
</template>
<template slot="control" data-control="raise" data-label="Raise hand" data-icon="raisehand"></template>
</call-screen>
  • Templates: ring-card, call-status, and control, a button of yours in the call controls. When it is pressed, the page hears realtime-control, with detail.control its name.
  • Parts: ring-card, call-window, call-status, video-tile, self-view, call-controls, grid-tile.

<call-spot>​

A call shows in a window in the corner, over the page. A <call-spot> shows the calls it names in the page itself, where you put it:

<call-spot call="support:{a}:{b}" style="height: 480px">
<img src="/agent.jpg" alt="Your support agent">
</call-spot>
Attribute
callthe calls it shows: the name of a call (support:34:42), a pattern as your rules write them (support:{a}:{b}), or a group call (meeting:daily). Without it, every call. Where two spots on a page take the same call, the one that names it most closely wins: its name, then a pattern, then every call
joinvideo or audio: joins the group call call names as the spot comes onto the page, as its <room-button> would, with the camera and microphone off. Once: someone who leaves it is not brought back while the spot stays
join-withwhat join turns on as it joins: microphone, camera, or microphone camera. Without it, nothing: the person turns them on from the call's controls
  • It moves, and goes on: a call shows in the spot as it starts. Where your pages change without loading anew, as with the links of Next.js, it goes on in the window on another page, and comes back when the page with the spot opens again, its camera, microphone and time as they were. A page that loads anew ends the call, so the browser asks before one opens.
  • Its size is the one your page gives it, 360px high when you give none, and the call fills it.
  • What is inside shows while no call is there. With nothing inside, the spot takes no place until a call comes.
  • data-call holds the name of the call while one is in it, for your CSS: call-spot[data-call] { … }.
  • The ring still shows in the corner, on any page.

Straight into a meeting​

With join, opening the page is enough: the person is in the meeting, with no button to press. Your server writes join only while the meeting is on, so the first one in still starts it with the button inside:

<!-- join only while someone is in it: realtime.call().get() -->
<call-spot call="meeting:7" join="video" style="height: 480px">
<room-button room="meeting:7">Start the meeting</room-button>
</call-spot>
  • Your rule decides, as for the button: someone it turns away sees why.
  • Once. Someone who leaves, or whom the host takes out, stays out while the page is open. Opening the page again joins again.
  • One call at a time. Someone already in another call stays in it. Someone already in this one finds it moved into the spot.
  • A name, not a pattern: a spot for meeting:{id}, or for every call, joins nothing.

They come in with the camera and microphone off, and the browser asks for neither until they turn one on from the call's controls. To have them on as people come in, join-with names them:

<call-spot call="meeting:7" join="video" join-with="microphone">
  • join-with is microphone, camera, or microphone camera: the browser asks for them as the page opens, and for the camera only on a video call.
  • <room-button> turns on both, as before: whoever presses it means to come in on camera.
  • Sound. A browser plays sound only once the person has clicked or typed on the page, or on the page of your site they came from. A page opened straight into a meeting, from a link in a new tab say, shows the others and Turn sound on over the call: their voices start at that click, or at any other on the page.

<live-stream>​

<live-stream name="show:mugs" title="The new mugs"></live-stream>
Attribute
namethe stream, as your streams() rule allows it
viewthe whole stream (the default), or one part: player, chat, details, studio, or studio-page, the studio as a page of its own
titlethe title of the stream
covera picture behind the player before the stream starts and after it ends
urlthe page to share, this one by default
login-urlwhere a visitor signs in to write in the chat
studio-urla page of its own where the host goes live: here the host sees the way there in place of the studio
back-urlon the studio page, its way back, such as the host's list of streams
chatoff for the stream without its chat
heightthe height of a chat apart, in pixels
stickykeeps the player at the top of a phone while live
  • The parts of one stream share one join and one chat, wherever they are: <live-stream name="show:mugs" view="player"> in the page, view="chat" in its side column.
  • What the page user sees follows the answer of your rule: the studio for its host, the player and the chat for everyone else, with what keeps the chat for its mods.
  • A refusal shows its words in place of the stream: no access, or live streaming not in the plan.
  • A live stream is not encrypted end to end, the chat and the picture alike.
  • Its look is drawn in the page, not in a shadow root: style its estream- classes (customizing).

<stream-studio>​

<stream-studio name="show:mugs"></stream-studio>

The studio alone: the camera and microphone, the picture before going live, streaming from OBS, Go live and End stream. Nothing for anyone the rule does not make the host.

The studio as a page of its own​

For a host who goes live often, a page of your own with nothing but the studio, which every page of the stream points them to with studio-url:

<!-- on the page viewers watch -->
<live-stream name="show:mugs" studio-url="/studio/mugs"></live-stream>

<!-- on /studio/mugs -->
<live-stream name="show:mugs" view="studio-page" title="The new mugs" url="/shows/mugs" back-url="/studio"
style="display: block; height: calc(100vh - 64px)"></live-stream>
  • On the page viewers watch, the host sees Go live in the studio over the player, and while live Open the studio, in place of the studio.
  • The studio page has the picture as large as fits, with Go live, the camera and microphone, the screen and OBS under it, and the statistics while live. Beside it, in tabs: the chat, the guests (the hands raised, with Invite, and those on stage), and the stream, with the link to share.
  • url is the page viewers watch, shown as View page and as the link to share. back-url puts a way back before the title.
  • Its height is the element's: give it display: block and a height, as the page around it leaves. Under 820 pixels wide, the tabs go under the picture.
  • Anyone else who opens it, whom the rule does not make the host, is told only hosts go live there.

Their words and look​

  • Words: in the language of the page <html lang>, in English, German, Spanish, French, Italian, Dutch, Polish, Croatian and Hebrew. rt.callScreen( { lang, strings } ) and rt.streamScreen( { lang, strings } ) choose another and change any of them by their English text.
  • Light and dark: they follow the system, or the page when it says which: wplus-messages-light or wplus-messages-dark on <body>, or a color-scheme naming one alone.
  • Right to left: a page in Hebrew draws them mirrored.
  • Design tokens, such as --wplus-color-accent, go on the elements themselves, since each keeps its own in its shadow root: call-screen, chat-room, online-list { --wplus-color-accent: 37, 99, 235; }. Set there, they hold in light and dark alike (customizing). The streams have a look of their own, their estream- classes.