@molecule/app-presence-indicator-svelte

Feature · presence-indicator · App (browser) · v1.1.4 · Apache-2.0

Online/offline dot + presence overlay for avatars and user chips

npm install @molecule/app-presence-indicator-svelte

npm · Source on GitHub

How it works

@molecule/app-presence-indicator-svelte is a ready-made presence-indicator feature for the app (browser) side. It composes the core interfaces it needs, so it works with whichever providers your app has bonded.

<script lang="ts">
  import { AvatarWithPresence, PresenceDot } from '@molecule/app-presence-indicator-svelte'

  const user = { avatarUrl: '/avatar.png', name: 'Ada' }
</script>

<!-- Inline dot next to a user name -->
<span>{user.name} <PresenceDot status="online" /></span>

<!-- Dot overlaid on an avatar image -->
<AvatarWithPresence status="away" corner="bottom-right">
  <img src={user.avatarUrl} alt={user.name} width={40} height={40} />
</AvatarWithPresence>

Works with: @molecule/app-svelte, @molecule/app-ui, @molecule/app-ui-svelte

Reference

Svelte presence indicator primitives — the Svelte counterpart of @molecule/app-presence-indicator-react, with the same props and the same DOM for the same input.

Exports:

  • PresenceDot — small colored status dot (online/away/busy/offline).
  • AvatarWithPresence — wraps any avatar and overlays a presence dot.
  • PresenceStatus type.

Auto-generated, AI-first package reference for the molecule.dev ecosystem. It is written to be read by coding agents as much as by people, and is generated from this package's source — edit src/index.ts JSDoc, not this file.

Quick Start

<script lang="ts">
  import { AvatarWithPresence, PresenceDot } from '@molecule/app-presence-indicator-svelte'

  const user = { avatarUrl: '/avatar.png', name: 'Ada' }
</script>

<!-- Inline dot next to a user name -->
<span>{user.name} <PresenceDot status="online" /></span>

<!-- Dot overlaid on an avatar image -->
<AvatarWithPresence status="away" corner="bottom-right">
  <img src={user.avatarUrl} alt={user.name} width={40} height={40} />
</AvatarWithPresence>

Type

feature

Installation

npm install @molecule/app-presence-indicator-svelte @molecule/app-svelte @molecule/app-ui @molecule/app-ui-svelte svelte

API

Interfaces

PresenceDotProps

Props accepted by the PresenceDot component.

interface PresenceDotProps {
  /** The presence state to display. */
  status: PresenceStatus
  /** Diameter in pixels. Defaults to 10. */
  size?: number
  /** Position — `'inline'` default; `'overlay'` positions absolutely for avatar overlays. */
  position?: 'inline' | 'overlay'
  /** Overlay corner when `position="overlay"`. Defaults to `'bottom-right'`. */
  corner?: 'top-right' | 'bottom-right' | 'top-left' | 'bottom-left'
  /** Accessible label override; defaults to `t('presenceIndicator.aria.presence', …)`. */
  ariaLabel?: string
  /** Extra classes. */
  className?: string
}

AvatarWithPresenceProps

Props accepted by the AvatarWithPresence component.

interface AvatarWithPresenceProps {
  /**
   * The avatar / media to decorate. Omitted renders no child; React declares
   * it required, but an absent child renders nothing either way.
   */
  children?: Snippet
  /** Presence status; omit to hide the dot. */
  status?: PresenceStatus
  /** Corner placement of the dot. Defaults to `'bottom-right'`. */
  corner?: 'top-right' | 'bottom-right' | 'top-left' | 'bottom-left'
  /** Dot size. Defaults to 10. */
  dotSize?: number
  /** Extra classes on the outer wrapper. */
  className?: string
}

Types

PresenceStatus

Union of supported user-presence states displayed by the dot.

type PresenceStatus = 'online' | 'away' | 'busy' | 'offline'

Constants

AvatarWithPresence

const AvatarWithPresence: LegacyComponentType

PresenceDot

const PresenceDot: LegacyComponentType

Injection Notes

Requirements

Peer dependencies:

  • @molecule/app-svelte ^3.5.0 || ^4.0.0
  • @molecule/app-ui ^1.0.1
  • @molecule/app-ui-svelte ^1.6.0
  • svelte ^5.0.0

Runtime Dependencies

  • @molecule/app-svelte
  • @molecule/app-ui
  • @molecule/app-ui-svelte
  • svelte

The default aria-label is the English string "Presence: <status>" — pass ariaLabel (e.g. from t()) in localized apps; the package has no locale bond. position="overlay" positions absolutely, so the dot must sit inside a relatively-positioned parent — AvatarWithPresence provides that wrapper. Status colors are fixed semantic hues (green/yellow/red/gray), identical in both themes; the overlay ring color follows var(--color-surface). The decorated avatar is the default children snippet; a node prop (the React form) may also arrive as a same-named snippet.

Translations

Translation strings are provided by @molecule/app-locales-presence-indicator.