Apps

Email

A full mail client: folders, labels, threads, a floating composer and keyboard shortcuts. The reference app for plugging in a backend.

composables/apps/useEmail.ts
View in the demo

Email is the reference app: if you understand how it loads, filters and saves data, you understand all of them. Messages that share a threadId form one conversation: the list shows one row per conversation, actions apply to the whole conversation and the reader shows the thread with older messages collapsed and an inline reply.

Every app follows the same pattern: typed models in types/models/, demo data in mocks/, state and actions in a composable under composables/apps/, page-only components in components/pages/<app>/ and UI strings in locales/<code>/apps.json. Read the apps overview once and every app looks familiar.

Files

File
Role
pages/email.vueThe page: split view, selection and keyboard shortcuts.
composables/apps/useEmail.tsState, filters, conversations and actions.
types/models/email.tsMessages, conversations, folders, labels and the provider.
config/email.config.tsFolders, labels and the default reading pane.
mocks/email.mock.tsDemo messages and createEmailMockProvider().
components/pages/email/EmailFolderNav, EmailList, EmailListItem, EmailReader, EmailThreadMessage, EmailComposer, EmailRecipientField.

Data and provider

types/models/email.ts
export interface EmailMessage {
  id: string
  threadId: string
  folder: string
  from: EmailSender
  to: string
  cc?: string
  subject: string
  body: string[]
  sentAt: string
  read: boolean
  starred: boolean
  labels: string[]
  attachments: EmailAttachment[]
}

export interface EmailProvider {
  list: () => Promise<EmailMessage[]>
  update: (ids: string[], patch: EmailMessagePatch) => Promise<void>
  send: (message: EmailMessage) => Promise<void>
}

Connect your backend

The page calls useEmail() with the mock provider. Write a provider that calls your API with useApi() and pass it in the page. The composable loads it through useAsyncData and applies every change optimistically, so the interface does not wait for the server.

providers/email.ts
import type { EmailMessage, EmailProvider } from '~/types/models/email'

export function createEmailApiProvider(): EmailProvider {
  const api = useApi()

  return {
    list: () => api<EmailMessage[]>('/messages'),
    update: (ids, patch) => api('/messages', { method: 'PATCH', body: { ids, patch } }),
    send: (message) => api('/messages', { method: 'POST', body: message }),
  }
}
pages/email.vue
<script setup lang="ts">
import { createEmailApiProvider } from '~/providers/email'

const { ... } = useEmail({ provider: createEmailApiProvider() })
</script>

Keep ids in your data and labels in the locales: folders, labels and tags resolve their names through apps.<app>.* unless you give them a raw title. See Connect your API for the token, validation errors and the actions the demo only fakes.

Configuration

EMAIL_FOLDERS

Folders as data: icon, count (unread or total) and an optional filter for virtual folders such as Starred.

config/email.config.ts
const EMAIL_FOLDERS: EmailFolderConfig[]

EMAIL_LABELS

Labels with their color and an optional raw title; otherwise the name comes from apps.email.labels.<id>.

config/email.config.ts
const EMAIL_LABELS: EmailLabelConfig[]

EMAIL_DEFAULT_VIEW

The reading pane the first time: right, none or drawer. The user’s choice persists in the email-view cookie.

config/email.config.ts
const EMAIL_DEFAULT_VIEW: EmailViewSettings

How it works

  • The page is a BaseSplitView: folders in nav (lg+), the list, the reader in detail. On phones the reader replaces the list.
  • Compose is the floating EmailComposer, not a dialog. Recipients are chips from EmailRecipientField, a BaseCombobox that suggests contacts and validates each address.
  • List rows switch to a one-line layout through the email-list container query when the list is at least 720px wide.
  • Times come from useRelativeDay() and stay empty until mount, so a server in another time zone cannot cause a hydration mismatch.
  • Attachments render with BaseAttachment.

Keyboard shortcuts

Registered with useHotkey in pages/email.vue and shown in the tooltips of their buttons.

Key
Action
j / kNext / previous conversation
eArchive
sStar
uMark as unread
rReply
cCompose
/Search
escClose the conversation
© 2026 melsami UI.
Developer documentation for melsami UI.