Presence
Another person's pointer, caret or selection, in the color that names them.
On this page
Presence shows where the other people working on the same thing are: their pointers on a canvas or a board, their carets and selections in text. Each person is drawn in one identity color, with their name beside it, so a reader can tell who is where at a glance. Add presence and the person's identity, presence-1 to presence-8, to an element that holds a presence-name, inside the positioned element the pointers move over, and set where it stands with --presence-x and --presence-y.
Presence
<div class="sheet relative overflow-hidden w-full max-w(520) h(264)" id="board"> <div class="texture texture-grid absolute inset(0)"></div> <div class="sheet sheet-raised absolute p-md text-sm w(168)" style="top: 32px; left: 28px"> <p class="m(0) fg-text-strong">Launch checklist</p> <p class="m(0) mt-xs fg-text-muted">Docs, changelog and the post</p> </div> <div class="sheet sheet-raised absolute p-md text-sm w(168)" style="top: 128px; left: 260px"> <p class="m(0) fg-text-strong">Open questions</p> <p class="m(0) mt-xs fg-text-muted">Who writes the release notes?</p> </div> <div class="presence presence-6" style="--presence-x: 150px; --presence-y: 78px" aria-hidden="true"> <span class="presence-name">Ada Lovelace</span> </div> <div class="presence presence-4" id="moving" style="--presence-x: 340px; --presence-y: 40px" aria-hidden="true"> <span class="presence-name">Alan Turing</span> </div> <div class="presence presence-8" style="--presence-x: 96px; --presence-y: 176px" aria-hidden="true"> <span class="presence-name">Grace Hopper</span> <span class="presence-message">I can take the release notes</span> </div></div><script>const pointer = document.getElementById('moving')const path = [[340, 40], [372, 64], [398, 108], [360, 150], [318, 132], [300, 84]]let at = 0setInterval(() => { at = (at + 1) % path.length pointer.style.setProperty('--presence-x', path[at][0] + 'px') pointer.style.setProperty('--presence-y', path[at][1] + 'px')}, 700)</script>#Where a pointer stands
A pointer's tip is the point. --presence-x and --presence-y are its distance, in pixels, from the top-left corner of the nearest positioned element, usually the canvas or the board, which takes relative and overflow-hidden so a pointer near its edge is cut there. The application knows where each person is and when they leave: it adds a presence when someone arrives, sets the two properties as their pointer moves, and removes it when they go. The stylesheet does the drawing and the motion; there is no script of its own.
function move(person, x, y) { const pointer = board.querySelector(`[data-person="${person.id}"]`) pointer.style.setProperty('--presence-x', `${x}px`) pointer.style.setProperty('--presence-y', `${y}px`)}- Motion. A pointer glides to each new point in a straight line for 160ms, which turns the few positions a second a connection delivers into steady movement. With
prefers-reduced-motion: reduceit jumps. - Out of the way. A pointer takes no pointer event, so it never stands between the reader's own pointer and what is under it.
- Coordinates. Send them in the canvas's own units and convert them to the reader's view before setting the properties, so two people with different window sizes and zoom levels point at the same thing.
#A message
A presence-message under the name holds a few words the person is writing, as cursor chat does: a question about the thing they are pointing at. It wraps at 15rem. Remove it a few seconds after they stop writing.
#Identity colors
Hue in Master UI says a status, and here, a person. The theme has eight identity colors, --color-identity-1 to --color-identity-8, all at one lightness: a person keeps one of them for the session, and their name always stands beside it, so the color is never the only way to tell people apart. --color-identity-ink is the text on every one of them, at a contrast of at least 4.8:1 in the light scheme and 9:1 in the dark one.
Choose one with a modifier, presence-1 to presence-8, on a pointer, a caret, a selection or a name that stands alone. A product with colors of its own for people sets --presence-color instead; give it one of a lightness that --color-identity-ink reads on, or set that token too.
Identity colors
<span class="presence-name presence-1">Ada</span><span class="presence-name presence-2">Alan</span><span class="presence-name presence-3">Grace</span><span class="presence-name presence-4">Edsger</span><span class="presence-name presence-5">Barbara</span><span class="presence-name presence-6">Donald</span><span class="presence-name presence-7">Margaret</span><span class="presence-name presence-8">Ken</span><> <span className="presence-name presence-1">Ada</span> <span className="presence-name presence-2">Alan</span> <span className="presence-name presence-3">Grace</span> <span className="presence-name presence-4">Edsger</span> <span className="presence-name presence-5">Barbara</span> <span className="presence-name presence-6">Donald</span> <span className="presence-name presence-7">Margaret</span> <span className="presence-name presence-8">Ken</span></><span class="presence-name presence-1">Ada</span><span class="presence-name presence-2">Alan</span><span class="presence-name presence-3">Grace</span><span class="presence-name presence-4">Edsger</span><span class="presence-name presence-5">Barbara</span><span class="presence-name presence-6">Donald</span><span class="presence-name presence-7">Margaret</span><span class="presence-name presence-8">Ken</span><template> <span class="presence-name presence-1">Ada</span> <span class="presence-name presence-2">Alan</span> <span class="presence-name presence-3">Grace</span> <span class="presence-name presence-4">Edsger</span> <span class="presence-name presence-5">Barbara</span> <span class="presence-name presence-6">Donald</span> <span class="presence-name presence-7">Margaret</span> <span class="presence-name presence-8">Ken</span></template>Hand the colors out in this order as people arrive, and give the color of someone who left to the next to come. Choose from a stable number, such as a hash of the person's id, when every reader must see the same person in the same color. With more than eight people, colors repeat; the names still tell them apart.
#In text
In a document edited together, another person's caret is a presence-caret between two letters: a 2px bar in their color, as tall as the line, with their name in a flag that stands on it. It takes no room, so the words around it do not move as it does. Their selection is a presence-selection around the words they selected: a tint of their color behind the words, carried across lines.
A caret and a selection
<div class="sheet p-lg max-w(440)"> <p class="m(0) text-sm fg-text-body leading-md"> The release ships <span class="presence-selection presence-4">on Thursday, after the docs build</span><span class="presence-caret presence-4" aria-hidden="true"> <span class="presence-name">Alan</span> </span> passes, and the post goes out the same afternoon. Ada writes the changelog<span class="presence-caret presence-6" aria-hidden="true"> <span class="presence-name">Ada</span> </span> while Grace checks the links. </p></div><div className="sheet p-lg max-w(440)"> <p className="m(0) text-sm fg-text-body leading-md"> The release ships <span className="presence-selection presence-4">on Thursday, after the docs build</span><span className="presence-caret presence-4" aria-hidden="true"> <span className="presence-name">Alan</span> </span> passes, and the post goes out the same afternoon. Ada writes the changelog<span className="presence-caret presence-6" aria-hidden="true"> <span className="presence-name">Ada</span> </span> while Grace checks the links. </p></div><div class="sheet p-lg max-w(440)"> <p class="m(0) text-sm fg-text-body leading-md"> The release ships <span class="presence-selection presence-4">on Thursday, after the docs build</span><span class="presence-caret presence-4" aria-hidden="true"> <span class="presence-name">Alan</span> </span> passes, and the post goes out the same afternoon. Ada writes the changelog<span class="presence-caret presence-6" aria-hidden="true"> <span class="presence-name">Ada</span> </span> while Grace checks the links. </p></div><template> <div class="sheet p-lg max-w(440)"> <p class="m(0) text-sm fg-text-body leading-md"> The release ships <span class="presence-selection presence-4">on Thursday, after the docs build</span><span class="presence-caret presence-4" aria-hidden="true"> <span class="presence-name">Alan</span> </span> passes, and the post goes out the same afternoon. Ada writes the changelog<span class="presence-caret presence-6" aria-hidden="true"> <span class="presence-name">Ada</span> </span> while Grace checks the links. </p> </div></template>The editor puts these marks where its collaboration layer says the other people are, as decorations it renders and removes; they are not part of the document. Leave room above the first line for a name flag, or let the flag of a caret on the first line run into the padding of what holds the text.
#When to use something else
- Who is here, rather than where, is a pile of avatars in the header.
- The mark at the end of text the application is still writing is a caret.
- Words highlighted for the reader, such as a search match, are a mark.
#Accessibility
- Pointers and carets are decoration: give each
aria-hidden="true", so their names are not read in the middle of a canvas or a sentence. Say who is here in words elsewhere, such as the avatars in the header with their names, and announce arrivals and departures in a polite live region if they matter to the task. - A selection is not hidden: the words in it are the document's. The tint does not change the words' color, so they keep their contrast.
- A color is never the only clue: the name stands beside every pointer and caret.
- In forced colors the arrows and the caret are drawn in system colors, and the flags and bubbles get an outline.
#Classes
| Class | Description |
|---|---|
presence | A pointer: an arrow whose tip stands at --presence-x and --presence-y in the positioned element that holds it, in the person's identity color. It glides to each new point and takes no pointer event |
presence-name | The person's name, in a flag of their color with the identity ink: beside the arrow's tip, standing on a caret, or on its own in a list of who is here |
presence-message | A short message the person is writing, in a bubble of their color under the name |
presence-caret | Another person's caret in text: an inline bar as tall as the line, in their identity color, that takes no room. A presence-name inside it stands on top of it |
presence-selection | Another person's selection: a tint of their identity color behind the words it holds, carried across lines |
presence-1 | Identity 1, --color-identity-1: red in hue. Without a modifier or --presence-color, a presence takes this oneApply with presence or presence-caret or presence-selection or presence-name |
presence-2 | Identity 2, --color-identity-2: orange in hueApply with presence or presence-caret or presence-selection or presence-name |
presence-3 | Identity 3, --color-identity-3: amber in hueApply with presence or presence-caret or presence-selection or presence-name |
presence-4 | Identity 4, --color-identity-4: green in hueApply with presence or presence-caret or presence-selection or presence-name |
presence-5 | Identity 5, --color-identity-5: teal in hueApply with presence or presence-caret or presence-selection or presence-name |
presence-6 | Identity 6, --color-identity-6: blue in hueApply with presence or presence-caret or presence-selection or presence-name |
presence-7 | Identity 7, --color-identity-7: violet in hueApply with presence or presence-caret or presence-selection or presence-name |
presence-8 | Identity 8, --color-identity-8: pink in hueApply with presence or presence-caret or presence-selection or presence-name |
#Custom properties
| Property | Default | Description |
|---|---|---|
--presence-color | var(--color-identity-1) | The person's color. A presence-1 to presence-8 modifier sets it to an identity; set it for a color of the product's own. Read by a presence, a presence-caret, a presence-selection and a presence-name |
--presence-x | 0px | Where the arrow's tip stands, from the left edge of the positioned element that holds it. The application sets it |
--presence-y | 0px | Where the arrow's tip stands, from the top edge of that element. The application sets it |
--presence-arrow | 1.25rem | The size of the arrow; the name stands beside its point |
#Related
- AvatarA person or a team as a photo or initials, alone or stacked.
- CaretThe mark at the end of text that is still being written.
- MarkA stroke of highlighter over the words that matter.