# Status and Presence

> Set a status that clears itself, or pause notifications. A person's card shows their local time.

Page: https://uicontext.com/docs/components/status-and-presence

Group: Chat.

## When to use

Set a status that clears itself, or pause notifications. A person's card shows their local time. Use [Avatar](https://uicontext.com/docs/components/avatar.md) instead when you only show whether someone is online.

## Usage

```ts
import { StatusPicker, type UserStatus } from "./ui/uicontext/components/Presence.ts"

const Message = UiSchema.TaggedEnum({
	SetStatus: { emoji: Schema.String, text: Schema.String, until: Schema.optional(Schema.String) },
	ClearedStatus: {},
	SetAway: { away: Schema.Boolean },
	Paused: { until: Schema.NullOr(Schema.String) },
})

// `until` is worked out from the reader's "Clear after" choice and `now`
export const Status = (h: Html.H<typeof Message.Type>, status: UserStatus | null, away: boolean, pausedUntil: string | null, now: string) =>
	StatusPicker(h, {
		props: { status, away, pausedUntil, now },
		onEmit: {
			RequestedStatus: (status) => Message.SetStatus(status),
			RequestedClearStatus: () => Message.ClearedStatus(),
			RequestedAway: ({ away }) => Message.SetAway({ away }),
			RequestedPause: ({ until }) => Message.Paused({ until }),
		},
	})
```

## Examples

Each example is a complete file. Its imports point where the CLI installs the source.

### Set a status

The example the page opens with: Status and Presence in “Set a status”.

This example also uses Domain. Install it too:

```sh
npx shadcn@latest add checkfu/uicontext/domain
```

```ts title="src/demo.ts" source="www/src/examples/status-and-presence/demo.ts"
import { UiSchema } from "effect/ui"
import { Html } from "effect/ui/html"
import * as stylex from "@stylexjs/stylex"
import { Schema } from "effect"
import { StatusPicker, UserStatus } from "./ui/uicontext/components/Presence.ts"
import { sx } from "./ui/uicontext/components/Sx.ts"
import { color, corner, space } from "./ui/uicontext/components/tokens.stylex.ts"
import { now } from "./chat.ts"

const styles = stylex.create({
	frame: { inlineSize: "min(100%, 24rem)", padding: space.lg, borderWidth: 1, borderStyle: "solid", borderColor: color.line, borderRadius: corner.card, backgroundColor: color.panel },
})

const Message = UiSchema.TaggedEnum({
	SetStatus: { status: Schema.NullOr(UserStatus) },
	SetAway: { away: Schema.Boolean },
	Paused: { until: Schema.NullOr(Schema.String) },
})

// Pick a suggestion or write your own, choose when it clears, go away, or pause notifications
export const MyStatus = Html.component({
	name: "MyStatus",
	model: Schema.Struct({ status: Schema.NullOr(UserStatus), away: Schema.Boolean, pausedUntil: Schema.NullOr(Schema.String) }),
	message: Message,
}).make({
	init: () => ({ status: null, away: false, pausedUntil: null }),
	update: {
		SetStatus: ($, { status }) => $.evolve({ status }),
		SetAway: ($, { away }) => $.evolve({ away }),
		Paused: ($, { until }) => $.evolve({ pausedUntil: until }),
	},
	view: (h, model) =>
		h.div.attrs(sx(styles.frame)).children(StatusPicker(h, {
			props: { status: model.status, away: model.away, pausedUntil: model.pausedUntil, now, timeZone: "America/Los_Angeles" },
			onEmit: {
				RequestedStatus: ({ emoji, text, until }) => Message.SetStatus({ status: { emoji, text, ...(until === undefined ? {} : { until }) } }),
				RequestedClearStatus: () => Message.SetStatus({ status: null }),
				RequestedAway: ({ away }) => Message.SetAway({ away }),
				RequestedPause: ({ until }) => Message.Paused({ until }),
			},
		})),
})
```

### Profile card

Status and Presence in “Profile card”.

This example also uses Domain. Install it too:

```sh
npx shadcn@latest add checkfu/uicontext/domain
```

```ts title="src/profile-card.ts" source="www/src/examples/status-and-presence/profile-card.ts"
import type { Html } from "effect/ui/html"
import * as stylex from "@stylexjs/stylex"
import { ProfileCard } from "./ui/uicontext/components/Presence.ts"
import { sx } from "./ui/uicontext/components/Sx.ts"
import { color, corner, elevation, space } from "./ui/uicontext/components/tokens.stylex.ts"
import { now } from "./chat.ts"

const styles = stylex.create({
	row: { display: "flex", flexWrap: "wrap", gap: space.lg },
	card: { borderWidth: 1, borderStyle: "solid", borderColor: color.line, borderRadius: corner.card, backgroundColor: color.overlay, boxShadow: elevation.raised },
})

// What opens on a name: presence, title, a status that clears itself, and the time where they are
export const ProfileCards = <M>(h: Html.H<M>) =>
	h.div.attrs(sx(styles.row)).children(
		h.div.attrs(sx(styles.card)).children(ProfileCard(h, {
			person: { id: "ben", name: "Ben Okafor", title: "Platform engineer" },
			presence: "active",
			status: { emoji: "📍", text: "Lisbon (UTC+0)" },
			timeZone: "Europe/Lisbon",
			now,
			message: "#dm-ben",
		})),
		h.div.attrs(sx(styles.card)).children(ProfileCard(h, {
			person: { id: "max", name: "Maximiliana Alexandra Featherstonehaugh-Worthington", title: "Principal staff engineer, platform reliability (EMEA)" },
			presence: "dnd",
			status: { emoji: "🎧", text: "Heads down on the billing ledger", until: "2026-12-01T17:00:00Z" },
			timeZone: "Pacific/Chatham",
			now,
			message: "#dm-max",
		})),
	)
```

### Sample data

The examples above import these files.

```ts title="src/chat.ts" source="www/src/examples/_shared/chat.ts"
import type { Actor } from "./ui/uicontext/components/domain/Actor.ts"

// A product team's workspace, for the team chat examples: its people and the time.

export const now = "2026-12-01T15:00:00Z"

export const maya: Actor = { id: "maya", name: "Maya Chen", kind: "person" }
export const ben: Actor = { id: "ben", name: "Ben Okafor", kind: "person" }
export const mira: Actor = { id: "mira", name: "Mira Patel", kind: "person" }
export const dana: Actor = { id: "dana", name: "Dana Ruiz", kind: "person" }
export const lena: Actor = { id: "lena", name: "Lena Fischer", kind: "person" }
```

## API reference

### StatusPicker (component)

**Props**

| Name | Type | Description |
| --- | --- | --- |
| `status` (required) | `UserStatus \| null` | The reader's status now, or null |
| `away` (required) | `boolean` | The reader set themselves away |
| `pausedUntil` (required) | `string \| null` | Notifications are paused until this time (ISO), or null |
| `now` (required) | `string` | The time now (ISO), for "until 3:30 PM" |
| `timeZone` | `string` | — |
| `agentId` | `string` | — |

**Events**

| Event | Payload | Description |
| --- | --- | --- |
| `RequestedStatus` | `{ emoji: string; text: string; until?: string }` | Set the reader's status; `until` is when it clears, worked out from their choice |
| `RequestedClearStatus` | `{}` | — |
| `RequestedAway` | `{ away: boolean }` | Show the reader as away (or active again) |
| `RequestedPause` | `{ until: string \| null }` | Pause notifications until `until` (ISO), or resume them (null) |

**Agent actions**

| Action | Description |
| --- | --- |
| `ClickedPreset` | Fill in a status: emoji, text and when it clears (never, 30m, 1h, 4h, today, week) |
| `SubmittedStatus` | Save the status being written |
| `ClickedClear` | Clear the reader's status |
| `ClickedPause` | Pause notifications: 30m, 1h, 2h or tomorrow |

### ProfileCard (view function)

**Options**

| Name | Type | Description |
| --- | --- | --- |
| `person` (required) | `{ readonly id: string; readonly name: string; readonly title?: string \| undefined; readonly agent?: boolean \| undefined }` | — |
| `presence` | `"active" \| "away" \| "dnd" \| "offline"` | — |
| `status` | `UserStatus \| null` | — |
| `timeZone` | `string` | The person's time zone (IANA): the card shows their local time |
| `now` (required) | `string` | The time now, ISO |
| `message` | `string` | A printed route to their DM |
| `call` | `((button: ButtonBuilder<Message>) => ButtonBuilder<Message>)` | Binds the Call button's press; no button without it |
| `extra` | `View.Input` | — |

## Keyboard and accessibility

- The status form names its field and its Clear after select; suggestions are buttons. Away is a toggle button, and paused notifications are announced with when they resume.
- A profile card names the person and reads their presence, status and local time as text; Message is a link and Call a button.

## Installation

```sh
pnpm dlx shadcn@latest add checkfu/uicontext/status-and-presence
```

With npm: `npx shadcn@latest add checkfu/uicontext/status-and-presence`. With yarn: `yarn dlx shadcn@latest add checkfu/uicontext/status-and-presence`. With bun: `bunx --bun shadcn@latest add checkfu/uicontext/status-and-presence`.

It writes these files:

- `src/ui/uicontext/components/Button.ts`
- `src/ui/uicontext/components/ChannelSidebar.ts`
- `src/ui/uicontext/components/Emoji.core.ts`
- `src/ui/uicontext/components/Emoji.ts`
- `src/ui/uicontext/components/Glyph.ts`
- `src/ui/uicontext/components/IconStroke.ts`
- `src/ui/uicontext/components/Popover.ts`
- `src/ui/uicontext/components/Presence.ts`
- `src/ui/uicontext/components/Reactions.ts`
- `src/ui/uicontext/components/Spoken.ts`
- `src/ui/uicontext/components/Sx.ts`
- `src/ui/uicontext/components/agent/Agent.ts`
- `src/ui/uicontext/components/button.stylex.ts`
- `src/ui/uicontext/components/domain/Format.ts`
- `src/ui/uicontext/components/domain/Glyph.ts`
- `src/ui/uicontext/components/domain/Time.ts`
- `src/ui/uicontext/components/tokens.stylex.ts`
- `src/ui/uicontext/components/variants.ts`

And installs the npm packages `@stylexjs/stylex`, `effect`.

## Source

- [src/Presence.ts](https://github.com/checkfu/uicontext/blob/main/src/Presence.ts)

## Used in

- [Team chat](https://uicontext.com/blocks/team-chat.md)

## Related

- [Conversation](https://uicontext.com/docs/components/conversation.md) (`conversation`): What a person and an assistant say to each other, with actions, sources and tool calls on each message.
- [Composer](https://uicontext.com/docs/components/composer.md) (`composer`): Write and send a message, with attachments and modes.
- [Conversation Viewport](https://uicontext.com/docs/components/conversation-viewport.md) (`conversation-viewport`): Keeps the newest message in view, and lets you scroll back without losing your place.
- [Streaming Text](https://uicontext.com/docs/components/streaming-text.md) (`streaming-text`): A reply that appears as it's written, with a stop button.
- [Agent Plan](https://uicontext.com/docs/components/agent-plan.md) (`agent-plan`): What an agent did and plans to do, step by step, with each step's input and result.
- [Tool Call](https://uicontext.com/docs/components/tool-call.md) (`tool-call`): What an assistant's tools did, one past-tense row each, such as "Searched the web · 8 sources". Each opens to what it read.
