@molecule/app-presence-indicator-vue
Feature · presence-indicator · App (browser) · v1.1.2 · Apache-2.0
Online/offline dot + presence overlay for avatars and user chips
npm install @molecule/app-presence-indicator-vueHow it works
@molecule/app-presence-indicator-vue 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.
import { defineComponent, h } from 'vue'
import { AvatarWithPresence, PresenceDot } from '@molecule/app-presence-indicator-vue'
const User = defineComponent({
props: { avatarUrl: String, name: String },
setup(props) {
return () =>
h('div', [
// Inline dot next to a user name
h('span', [props.name, h(PresenceDot, { status: 'online' })]),
// Dot overlaid on an avatar image
h(
AvatarWithPresence,
{ status: 'away', corner: 'bottom-right' },
{
default: () => [
h('img', { src: props.avatarUrl, alt: props.name, width: 40, height: 40 }),
],
},
),
])
},
})Works with: @molecule/app-ui, @molecule/app-ui-vue, @molecule/app-vue
Reference
Vue presence indicator primitives.
Exports:
<PresenceDot>— small colored status dot (online/away/busy/offline).<AvatarWithPresence>— wraps any avatar and overlays a presence dot.PresenceStatustype.
It is the Vue counterpart of @molecule/app-presence-indicator-react: the
same props (React names), the same DOM for the same input.
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.tsJSDoc, not this file.
Quick Start
import { defineComponent, h } from 'vue'
import { AvatarWithPresence, PresenceDot } from '@molecule/app-presence-indicator-vue'
const User = defineComponent({
props: { avatarUrl: String, name: String },
setup(props) {
return () =>
h('div', [
// Inline dot next to a user name
h('span', [props.name, h(PresenceDot, { status: 'online' })]),
// Dot overlaid on an avatar image
h(
AvatarWithPresence,
{ status: 'away', corner: 'bottom-right' },
{
default: () => [
h('img', { src: props.avatarUrl, alt: props.name, width: 40, height: 40 }),
],
},
),
])
},
})
Type
feature
Installation
npm install @molecule/app-presence-indicator-vue @molecule/app-ui @molecule/app-ui-vue @molecule/app-vue vue
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. Passed as the default slot or as a
* `children` prop — both work.
*/
children?: VNodeChild
/** 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
Wraps any avatar/image and overlays a presence dot at a corner.
Non-destructive — just positions the dot; the child is untouched. The
child arrives as the default slot or as a children prop; the slot wins.
const AvatarWithPresence: DefineComponent<
ExtractPropTypes<{
children: null
status: { type: PropType<PresenceStatus>; default: undefined }
corner: {
type: PropType<'top-right' | 'bottom-right' | 'top-left' | 'bottom-left'>
default: string
}
dotSize: { type: NumberConstructor; default: undefined }
className: { type: StringConstructor; default: undefined }
}>,
() => VNode,
{},
{},
{},
ComponentOptionsMixin,
ComponentOptionsMixin,
{},
string,
PublicProps,
Readonly<
ExtractPropTypes<{
children: null
status: { type: PropType<PresenceStatus>; default: undefined }
corner: {
type: PropType<'top-right' | 'bottom-right' | 'top-left' | 'bottom-left'>
default: string
}
dotSize: { type: NumberConstructor; default: undefined }
className: { type: StringConstructor; default: undefined }
}>
> &
Readonly<{}>,
{
status: PresenceStatus
corner: 'top-right' | 'bottom-right' | 'top-left' | 'bottom-left'
dotSize: number
className: string
},
{},
{},
{},
string,
ComponentProvideOptions,
true,
{},
any
>
props— Component props (seeAvatarWithPresenceProps).
Returns: The avatar-with-presence component.
PresenceDot
Small colored circle indicating user presence. Use inline next to a name,
or with position="overlay" attached to the corner of an avatar.
The default aria-label resolves through t() with the
presenceIndicator.aria.presence key (an explicitly translated status word
per presenceIndicator.status.* key), so it follows the active locale;
ariaLabel overrides it.
const PresenceDot: DefineComponent<
ExtractPropTypes<{
status: { type: PropType<PresenceStatus>; required: true }
size: { type: NumberConstructor; default: number }
position: { type: PropType<'inline' | 'overlay'>; default: string }
corner: {
type: PropType<'top-right' | 'bottom-right' | 'top-left' | 'bottom-left'>
default: string
}
ariaLabel: { type: StringConstructor; default: undefined }
className: { type: StringConstructor; default: undefined }
}>,
() => VNode,
{},
{},
{},
ComponentOptionsMixin,
ComponentOptionsMixin,
{},
string,
PublicProps,
Readonly<
ExtractPropTypes<{
status: { type: PropType<PresenceStatus>; required: true }
size: { type: NumberConstructor; default: number }
position: { type: PropType<'inline' | 'overlay'>; default: string }
corner: {
type: PropType<'top-right' | 'bottom-right' | 'top-left' | 'bottom-left'>
default: string
}
ariaLabel: { type: StringConstructor; default: undefined }
className: { type: StringConstructor; default: undefined }
}>
> &
Readonly<{}>,
{
corner: 'top-right' | 'bottom-right' | 'top-left' | 'bottom-left'
className: string
size: number
position: 'inline' | 'overlay'
ariaLabel: string
},
{},
{},
{},
string,
ComponentProvideOptions,
true,
{},
any
>
props— Component props (seePresenceDotProps).
Returns: The presence dot component.
Injection Notes
Requirements
Peer dependencies:
@molecule/app-ui^1.0.1@molecule/app-ui-vue^1.1.0@molecule/app-vue^3.5.0 || ^4.0.0vue^3.4.0
Runtime Dependencies
@molecule/app-ui@molecule/app-ui-vue@molecule/app-vuevue
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). Node-valued children arrive as the default slot or
as a children prop; the components accept either.
Translations
Translation strings are provided by @molecule/app-locales-presence-indicator.