---
title: "Marker"
description: "Marker with accessible presentation and local state."
---

# Marker

Marker with accessible presentation and local state.

## Installation

Install the shared package once in your Exact app. This version is a beta.

```sh
bun add --exact @rightui/ui@0.4.0-beta.4
```

Or choose another package manager:

```sh
npm install --save-exact @rightui/ui@0.4.0-beta.4
pnpm add --save-exact @rightui/ui@0.4.0-beta.4
yarn add --exact @rightui/ui@0.4.0-beta.4
```

Exact compilation uses Bun 1.4.2. Register Geist and Newsreader, declare the font marker and add the root provider using [Installation](/docs/installation).

### Manual source setup

Install an editable copy of the complete package:

```sh
mkdir -p vendor/rightui vendor/rightui-ui
npm pack @rightui/ui@0.4.0-beta.4 --pack-destination vendor/rightui
tar -xzf ./vendor/rightui/rightui-ui-0.4.0-beta.4.tgz -C vendor/rightui-ui --strip-components=1
bun add file:./vendor/rightui-ui
```

Keep package.json, the Contract files, ui.tamber, assets and licenses together.

### Import

```contract
use Marker from "@rightui/ui"
```

## Usage

Import Marker from @rightui/ui. Supply content and required properties as shown in the example.

## Example

```contract
use FontWeights from "@rightui/ui"
use uiFontFamily, Marker from "@rightui/ui"

component Demo
  props
    width: number
    reduced: bool
  inject
    uiWeights: FontWeights
    uiFont: string
  derive narrow = width < 600
  view
    column gap="ui.space-16" min-width=0 max-width="100%"
      Marker(id="content-marker", label="Today", variant="separator")
      text "Border" font-size="ui.text-sm" font-weight=uiWeights.semibold font-family=uiFontFamily(uiFont) data-rightui-font="body"
      Marker(id="variation-marker-border", label="Yesterday", variant="border")
      text "Plain" font-size="ui.text-sm" font-weight=uiWeights.semibold font-family=uiFontFamily(uiFont) data-rightui-font="body"
      Marker(id="variation-marker-plain", label="Yesterday", variant="plain")

```

## API Reference

| Property | Type |
| --- | --- |
| Marker.id | string |
| Marker.label | string |
| Marker.variant | string |

## Source

File: packages/ui/conversation.contract

```contract
use FontWeights from "./typography-context.contract"
use uiFontFamily from "./typography-context.contract"
use Control from "./styles.contract"
use AttachmentFrame, AttachmentMedia, AttachmentContent, AttachmentTitle, AttachmentDescription, AttachmentActions, AttachmentAction, AttachmentTrigger, AttachmentPreview from "./attachment-parts.contract"
use BubbleFrame from "./conversation-parts.contract"
use BubbleReactions from "./bubble-parts.contract"
use Avatar from "./display.contract"

component Attachment
  props
    id: string
    name: string
    metadata: string
    content: string
    status: string
    remove: action
  view
    AttachmentOptions(id=id, name=name, metadata=metadata, content=content, status=status, remove=remove, size="default", orientation="horizontal", imageSource="", cardWidth="", previewHref="", reduced=true, copyable=false, copyValue="")

component AttachmentOptions
  props
    id: string
    name: string
    metadata: string
    content: string
    status: string
    remove: action
    size: string
    orientation: string
    imageSource: string
    cardWidth: string
    previewHref: string
    reduced: bool
    copyable: bool
    copyValue: string
  inject
    uiFont: string
  state preview = false
  state copied = false
  action toggle
    preview = not preview
  action dismiss
    preview = false
    focus(id + "-preview")
  action copy
    copyText(copyValue == "" ? content : copyValue)
    copied = true
  view
    AttachmentFrame(id=id, status=status, size=size, orientation=orientation, cardWidth=cardWidth)
      AttachmentMedia(name=name, source=imageSource, status=status, size=size, orientation=orientation, reduced=reduced)
      AttachmentContent()
        AttachmentTitle(name=name, status=status, size=size, reduced=reduced)
        if metadata != ""
          AttachmentDescription(text=metadata, status=status)
      AttachmentActions(orientation=orientation)
        if copyable and (content != "" or copyValue != "")
          AttachmentAction(id=id + "-copy", label=(copied ? "Copied " : copyValue == "" ? "Copy " : "Copy link to ") + name, icon="copy", press=copy)
        AttachmentAction(id=id + "-remove", label="Remove " + name, icon="remove", press=remove)
      AttachmentTrigger(id=id + "-preview", label=(previewHref == "" ? "Preview " + name : "Open " + name + " (opens in a new tab)"), disabled=(status != "done"), expanded=preview, controls=id + "-dialog", href=(status == "done" ? previewHref : ""), press=toggle)
    if copied
      text ("Copied " + name) role="status" font-size="ui.text-xs" color="ui.muted-foreground" font-family=uiFontFamily(uiFont) data-rightui-font="body"
    AttachmentPreview(id=id + "-dialog", open=preview, name=name, metadata=metadata, content=content, contentId=id + "-content", imageSource=imageSource, reduced=reduced, dismiss=dismiss)

component Bubble
  props
    id: string
    body: string
    align: string
    variant: string
    collapsible: bool
  view
    BubbleOptions(id=id, body=body, align=align, variant=variant, collapsible=collapsible, reactions=true, reduced=true, initialCollapsed=false, previewLength=180)

component BubbleOptions
  props
    id: string
    body: string
    align: string
    variant: string
    collapsible: bool
    reactions: bool
    reduced: bool
    initialCollapsed: bool
    previewLength: number
  inject
    uiWeights: FontWeights
    uiFont: string
  state bubbleCollapsed: bool = initialCollapsed
  state bubbleReacted: bool = false
  derive shownBody = collapsible and bubbleCollapsed ? body.slice(0, previewLength) + (body.length > previewLength ? "…" : "") : body
  action toggle
    bubbleCollapsed = not bubbleCollapsed
  action react
    bubbleReacted = not bubbleReacted
  view
    BubbleFrame(id=id, align=align, variant=variant)
      column gap="ui.space-6" min-width="0px"
        text shownBody id=(id + "-body") testId=(id + "-body") font-size="ui.text-sm" line-height="ui.leading-code" white-space="pre-wrap" overflow-wrap="break-word" font-family=uiFontFamily(uiFont) data-rightui-font="body"
        if collapsible
          button id=(id + "-collapse") testId=(id + "-collapse") class=Control font-weight=uiWeights.medium press=toggle aria-expanded=(not bubbleCollapsed) aria-controls=(id + "-body") display="flex" align-items="center" gap="ui.space-4" padding="0px" min-height="ui.space-24" border="none" background-color="transparent" color="inherit" align-self="flex-start"
            text (bubbleCollapsed ? "Show more" : "Show less") font-size="ui.text-xs" font-family=uiFontFamily(uiFont) data-rightui-font="body"
            svg width="ui.space-14" height="ui.space-14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="ui.stroke-standard" rotate=(bubbleCollapsed ? "0deg" : "180deg") transition=(reduced ? "none" : "rotate ui.duration-fast ui.easing") aria-hidden=true
              path d="m6 9 6 6 6-6"
      if reactions
        BubbleReactions(id=id + "-reactions", label="Message reactions", side="bottom", align="end", interactive=true)
          button id=(id + "-reaction") testId=(id + "-reaction") class=Control font-weight=uiWeights.medium press=react aria-pressed=bubbleReacted aria-label="Helpful reaction" min-height="ui.space-24" padding="ui.space-2 ui.space-8" border="none" border-radius="ui.radius-full" background-color="transparent" color="ui.foreground"
            text (bubbleReacted ? "Helpful · 1" : "Helpful") font-size="ui.text-xs" font-family=uiFontFamily(uiFont) data-rightui-font="body"

component Marker
  props
    id: string
    label: string
    variant: string
  inject
    uiFont: string
  view
    row id=id testId=id gap="ui.space-8" align-items="center" min-height="ui.space-16" padding-bottom=(variant == "border" ? "ui.space-8" : "0px") border-bottom-width=(variant == "border" ? "ui.border-width" : "0px") border-bottom-style="solid" border-bottom-color="ui.border"
      if variant == "separator"
        view flex=1 height="ui.border-width" background-color="ui.border" aria-hidden=true
      text label font-size="ui.text-sm" color="ui.muted-foreground" overflow-wrap="break-word" font-family=uiFontFamily(uiFont) data-rightui-font="body"
      if variant == "separator"
        view flex=1 height="ui.border-width" background-color="ui.border" aria-hidden=true

component Message
  props
    id: string
    author: string
    initials: string
    time: string
    align: string
  slot
  view
    MessageRow(id=id, align=align)
      MessageAvatar()
        Avatar(id=id + "-avatar", src="", name=author, fallback=initials)
      MessageBody(align=align)
        if author != ""
          MessageHeader(label=author)
        children
        if time != ""
          MessageMeta(label=time, align=align)

component MessageGroup
  props
    id: string
  slot
  view
    column id=id testId=id gap="ui.space-8" width="100%" min-width="0px" max-width="100%"
      children

component MessageRow
  props
    id: string
    align: string
  slot
  view
    row id=id testId=id gap="ui.space-8" width="100%" min-width="0px" flex-direction=(align == "end" ? "row-reverse" : "row")
      children

component MessageAvatar
  slot
  view
    view flex-shrink=0 align-self="flex-end" width="ui.avatar-size" min-width="ui.avatar-size" display="flex" align-items="center" justify-content="center"
      children

component MessageBody
  props
    align: string
  slot
  view
    column gap="ui.space-10" flex=1 min-width="0px" align-items=(align == "end" ? "flex-end" : "flex-start") overflow-wrap="break-word"
      children

component MessageHeader
  props
    label: string
  inject
    uiWeights: FontWeights
    uiFont: string
  slot
  view
    row gap="ui.space-8" align-items="center" max-width="100%" min-width="0px" padding="0px ui.space-12"
      if label != ""
        text label font-size="ui.text-xs" font-weight=uiWeights.medium color="ui.muted-foreground" font-family=uiFontFamily(uiFont) data-rightui-font="body"
      children

component MessageMeta
  props
    label: string
    align: string
  inject
    uiFont: string
  slot
  view
    row gap="ui.space-8" align-items="center" justify-content=(align == "end" ? "flex-end" : "flex-start") align-self=(align == "end" ? "flex-end" : "flex-start") flex-wrap="wrap" max-width="100%" min-width="0px" padding="0px ui.space-12"
      if label != ""
        text label font-size="ui.text-xs" color="ui.muted-foreground" font-family=uiFontFamily(uiFont) data-rightui-font="body"
      children

keyframes uiTypingWave
  from translate="0px 0px"
  25% translate="0px -4px"
  50% translate="0px 0px"
  to translate="0px 0px"

component MessageTyping
  props
    id: string
    label: string
    reduced: bool
  inject
    uiFont: string
  view
    row id=id testId=id role="status" aria-label=label align-items="center" gap="ui.space-8" color="ui.muted-foreground"
      row aria-hidden=true gap="ui.space-4" align-items="center" height="ui.space-16"
        for dot in [0, 1, 2] key=dot
          view testId=(id + "-dot-" + dot.toString()) width="ui.space-4" height="ui.space-4" border-radius="ui.radius-full" background-color="currentColor" animation=(reduced ? "none" : ("uiTypingWave 1s ease-in-out " + (dot * 0.15).toString() + "s infinite"))
      text label font-size="ui.text-xs" font-family=uiFontFamily(uiFont) data-rightui-font="body"

```
