---
title: "MazIndicator"
description: "MazIndicator is a small dot or counter to show a status or a number of notifications. Use it alone, inline in a badge or a list row, or on the corner of an avatar, a button or an icon."
package: "maz-ui"
url: "https://maz-ui.com/components/maz-indicator"
---

# MazIndicator

> MazIndicator is a small dot or counter to show a status or a number of notifications. Use it alone, inline in a badge or a list row, or on the corner of an avatar, a button or an icon.

- Package: `maz-ui`
- Import: `import MazIndicator from 'maz-ui/components/MazIndicator'`
- Nuxt: auto-imported by `@maz-ui/nuxt`, no import needed in a Nuxt app
- Web: https://maz-ui.com/components/maz-indicator

> Before use it, you should install the MazUi plugin in your project, follow instructions in [Getting Started](../guide/getting-started.md)

## Basic usage

Without `content`, the indicator is a **dot**, to show a status (online, away, recording). Used alone, it is rendered inline and follows the font size of its context.

```vue
<script lang="ts" setup>
import MazIndicator from 'maz-ui/components/MazIndicator'
</script>

<template>
  <span class="inline-flex items-center gap-2"><MazIndicator color="success" /> Online</span>
  <span class="inline-flex items-center gap-2"><MazIndicator color="warning" /> Away</span>
  <span class="inline-flex items-center gap-2"><MazIndicator color="destructive" /> Busy</span>
</template>
```

## Counter

Set `content` to a **number** or a **short text** to get a counter (unread messages, notifications). Above `max` (`99` by default), a number shows `{max}+`.

```vue
<template>
  <MazIndicator :content="3" color="destructive" />
  <MazIndicator :content="42" color="destructive" />

  <!-- Above `max` (99 by default): 99+ -->
  <MazIndicator :content="128" color="destructive" />

  <!-- 128 -->
  <MazIndicator :content="128" :max="999" color="destructive" />

  <!-- A short text -->
  <MazIndicator content="New" color="info" />
</template>
```

### Show zero

A counter at `0` is hidden, like an empty notification count. Set `show-zero` to display it anyway. A text content (`'0'` for instance) is always displayed.

```vue
<template>
  <!-- Renders nothing -->
  <MazIndicator :content="0" />

  <MazIndicator :content="0" show-zero />
</template>
```

## Colors

Available colors: `primary` (default), `secondary`, `accent`, `info`, `success`, `warning`, `destructive` and `contrast`.

```vue
<template>
  <MazIndicator color="primary" />
  <MazIndicator color="success" />
  <MazIndicator color="destructive" :content="8" />
</template>
```

## Sizes

By default, the indicator is sized in `em`: it follows the font size of its context (a text, a badge, an avatar). Set `size` to force one of the maz-ui sizes.

```vue
<template>
  <MazIndicator size="mini" color="success" />
  <MazIndicator size="xs" color="success" />
  <MazIndicator size="sm" color="success" />
  <MazIndicator size="md" color="success" />
  <MazIndicator size="lg" color="success" />
  <MazIndicator size="xl" color="success" />

  <MazIndicator size="xl" :content="12" color="destructive" />
</template>
```

## On an element

Put content in the default slot (an avatar, a button, an icon): the indicator sits on one of its corners. The wrapper is an `inline-flex` element that takes the size of its content.

### Avatar

For an avatar, prefer the [`indicator` prop of MazAvatar](./maz-avatar.md#indicator), which sets the position and the overlap for you.

```vue
<script lang="ts" setup>
import MazAvatar from 'maz-ui/components/MazAvatar'
import MazIndicator from 'maz-ui/components/MazIndicator'
</script>

<template>
  <MazIndicator color="success" position="bottom-end" overlap="circular" label="Online">
    <MazAvatar caption="Camille Durand" color="auto" rounded-size="full" />
  </MazIndicator>

  <MazIndicator :content="3" color="destructive" overlap="circular" label="3 unread messages">
    <MazAvatar caption="Nina Rossi" color="auto" rounded-size="full" />
  </MazIndicator>
</template>
```

### Button

`MazBtn` clips its content (`overflow-hidden`): a prop on the button would be cut. Wrap the button in a `MazIndicator` instead. It works with a normal button and with a `fab` one.

```vue
<script lang="ts" setup>
import { MazBell } from '@maz-ui/icons/static/MazBell'
import MazBtn from 'maz-ui/components/MazBtn'
import MazIndicator from 'maz-ui/components/MazIndicator'
</script>

<template>
  <MazIndicator :content="3" color="destructive" label="3 new messages">
    <MazBtn>Inbox</MazBtn>
  </MazIndicator>

  <!-- A round fab button: `overlap="circular"` keeps the indicator on its edge -->
  <MazIndicator :content="12" color="destructive" overlap="circular" label="12 notifications">
    <MazBtn fab :icon="MazBell" aria-label="Notifications" />
  </MazIndicator>
</template>
```

### Icon

```vue
<script lang="ts" setup>
import { MazBell } from '@maz-ui/icons/static/MazBell'
import { MazEnvelope } from '@maz-ui/icons/static/MazEnvelope'
import MazIndicator from 'maz-ui/components/MazIndicator'
</script>

<template>
  <MazIndicator :content="5" color="destructive" label="5 notifications">
    <MazBell class="size-8" />
  </MazIndicator>

  <MazIndicator color="info">
    <MazEnvelope class="size-8" />
  </MazIndicator>
</template>
```

## Position and overlap

`position` sets the corner: `top-start`, `top-end` (default), `bottom-start` or `bottom-end`. Corners follow the reading direction (`start` and `end` flip in right-to-left languages).

`overlap` describes the shape of the content: on a `circular` one (a round avatar, a fab button), the indicator moves in to stay on the edge of the circle instead of floating in the empty corner.

```vue
<template>
  <!-- rectangular (default) -->
  <MazIndicator position="top-start" :content="1" color="destructive">
    <div class="size-12 rounded-md bg-surface-600" />
  </MazIndicator>

  <!-- circular -->
  <MazIndicator position="bottom-end" overlap="circular" :content="1" color="destructive">
    <div class="size-12 rounded-full bg-surface-600" />
  </MazIndicator>
</template>
```

## Attached

`attached` places the indicator on a corner of its **nearest positioned parent** (an element with `position: relative`), without wrapping anything. It is the way to add an indicator inside a component, like [MazAvatar](./maz-avatar.md) and [MazSidebarMenuButton](./maz-sidebar.md) do.

```vue
<template>
  <div class="relative size-12 rounded-md bg-surface-600">
    <MazIndicator attached :content="4" color="destructive" />
  </div>

  <div class="relative size-12 rounded-full bg-surface-600">
    <MazIndicator attached overlap="circular" position="bottom-end" color="success" />
  </div>
</template>
```

## Ring

A thin ring detaches the indicator from the content it sits on. `bordered` is `true` by default with a default slot or `attached`, and `false` when the indicator is inline. Set `:bordered="false"` to remove it.

The ring takes the color of the surface behind (the container background, or the page surface). On another background, such as a colored header, override the `--m-indicator-ring` CSS variable so the ring blends in.

```vue
<template>
  <header class="flex items-center gap-6 bg-primary p-6 [--m-indicator-ring:var(--maz-primary)]">
    <MazIndicator color="success" position="bottom-end" overlap="circular">
      <MazAvatar caption="Louis Mazel" color="auto" rounded-size="full" />
    </MazIndicator>
  </header>

  <MazIndicator :content="3" color="destructive" :bordered="false">
    <MazBtn>No ring</MazBtn>
  </MazIndicator>
</template>
```

## Pulse

`pulse` adds an animated halo around the indicator, for a live status (recording, incoming call). The animation is disabled when the user asks to reduce motion.

```vue
<template>
  <span class="inline-flex items-center gap-2"><MazIndicator color="destructive" pulse /> Recording</span>

  <MazIndicator :content="2" color="destructive" pulse label="2 incoming calls">
    <MazBtn>Calls</MazBtn>
  </MazIndicator>
</template>
```

## Invisible

`invisible` hides the indicator and keeps the wrapped content. Bind it to your state, for instance "no more unread messages".

```vue
<script lang="ts" setup>
import MazBtn from 'maz-ui/components/MazBtn'
import MazIndicator from 'maz-ui/components/MazIndicator'
import MazSwitch from 'maz-ui/components/MazSwitch'
import { ref } from 'vue'

const hidden = ref(false)
</script>

<template>
  <MazSwitch v-model="hidden">Invisible</MazSwitch>

  <MazIndicator color="success" :invisible="hidden">
    <MazBtn>Status</MazBtn>
  </MazIndicator>
</template>
```

## Custom content

The `content` slot replaces the text of a counter. It receives `{ text }`, the text computed from `content` and `max` (`99+` for instance). It is not rendered for a dot.

```vue
<template>
  <MazIndicator :content="250" color="destructive" label="250 unread messages">
    <template #content="{ text }">
      {{ text }} new
    </template>
  </MazIndicator>
</template>
```

## In a badge

A dot before the text of a pastel [MazBadge](./maz-badge.md) is a compact status.

```vue
<template>
  <MazBadge color="success" pastel class="gap-2">
    <MazIndicator color="success" /> Online
  </MazBadge>

  <MazBadge color="destructive" pastel class="gap-2">
    <MazIndicator color="destructive" pulse /> Live
  </MazBadge>
</template>
```

## In a list

Inline, the indicator fits the `end` slot of a [MazListItem](./maz-list.md) (a status or a count). For a member avatar, use the `indicator` prop of [MazAvatar](./maz-avatar.md#indicator).

```vue
<script lang="ts" setup>
import MazIndicator from 'maz-ui/components/MazIndicator'
import MazList from 'maz-ui/components/MazList'
import MazListItem from 'maz-ui/components/MazListItem'

const channels = [
  { name: 'General', unread: 12, live: false },
  { name: 'Design', unread: 0, live: true },
  { name: 'Random', unread: 0, live: false },
]
</script>

<template>
  <MazList title="Channels">
    <MazListItem v-for="channel in channels" :key="channel.name" :title="channel.name" clickable>
      <template #end>
        <MazIndicator
          v-if="channel.unread"
          :content="channel.unread"
          color="destructive"
          :label="`${channel.unread} unread messages`"
        />
        <MazIndicator v-else-if="channel.live" color="success" pulse label="Live" />
      </template>
    </MazListItem>
  </MazList>
</template>
```

## Accessibility

- Without `label`, the indicator is **decorative**: it is hidden from assistive technologies (`aria-hidden`). A status shown only by a colored dot is invisible to screen readers and ambiguous for color-blind users: set `label` ("Online", "3 unread messages") whenever the indicator carries information. With a `label`, it is exposed as an image (`role="img"`) named by `aria-label`.
- Give the label in the language of the page, and update it with the state (`:label="online ? 'Online' : 'Offline'"`).
- Do not rely on color alone for a status that matters: pair the dot with a text when you can (see "In a badge").
- The wrapped content keeps its own semantics. Name a button with an indicator on it (`aria-label`, or the `label` of the indicator for the count) and do not repeat the information twice.
- The indicator ignores pointer events (`pointer-events: none`) in a wrapper or when `attached`: the wrapped element stays clickable.
- `pulse` is turned off with `prefers-reduced-motion`.

## MazIndicator API

`import MazIndicator from 'maz-ui/components/MazIndicator'`

### Props

- `content` (`string | number`): Content of the indicator: a number for a counter (notifications, unread messages) or a short text. Without it, the indicator is a dot (a status).
- `max` (`number`, default: `99`): Highest number displayed by a counter: above, it shows `{max}+`.
- `show-zero` (`boolean`, default: `false`): Show the counter when its content is `0` (hidden by default, like an empty notification count).
- `color` (`"primary" | "secondary" | "accent" | "info" | "success" | "warning" | "destructive" | "contrast"`, default: `"primary"`): Color of the indicator.
- `position` (`MazIndicatorPosition`, default: `"top-end"`): Corner of the wrapped content where the indicator sits (with a default slot or `attached`). Values: `'top-start'`, `'top-end'`, `'bottom-start'`, `'bottom-end'` (non exhaustive).
- `overlap` (`"rectangular" | "circular"`, default: `"rectangular"`): Shape of the wrapped content: on a `circular` one (an avatar), the indicator moves in to stay on the edge of the circle.
- `size` (`"xs" | "sm" | "md" | "lg" | "xl" | "mini"`): Size of the indicator. Without it, it follows the font size of its context.
- `bordered` (`boolean`, default: `` true with a default slot or `attached`, false otherwise ``): Ring around the indicator to detach it from the wrapped content. It takes the container background: override `--m-indicator-ring` on another surface.
- `pulse` (`boolean`, default: `false`): Animated halo around the indicator (a live status). Disabled when the user reduces motion.
- `attached` (`boolean`, default: `false`): Place the indicator on a corner of its nearest positioned parent instead of inline, to add it to an element without wrapping it.
- `invisible` (`boolean`, default: `false`): Hide the indicator (the wrapped content stays).
- `label` (`string`): Accessible name of the indicator ("Online", "3 unread messages"...). Without it, the indicator is decorative and hidden from assistive technologies.

### Slots

- `#default`: Content on a corner of which the indicator sits (an avatar, a button, an icon)
- `#content`: Replace the text of a counter Bindings: `text: string`.
