Indicator

A dot or a count pinned to the corner of what it wraps.

Feedback Added in v0.41.0 Updated

Default

3

<div class="flex items-center gap-6">
	{ui indicator, value: '3', label: '3 unread'}
		{ui button,
			icon: 'bell',
			class: 'button-icon button-outline',
			attrs: ['aria-label' => 'Notifications'],
		/}
	{/ui}
	{ui indicator, label: 'New activity'}
		{ui button,
			icon: 'mail',
			class: 'button-icon button-outline',
			attrs: ['aria-label' => 'Mail'],
		/}
	{/ui}
</div>

The tag's content is whatever the mark sits on: a button, an avatar, an icon. Without value the mark is a plain dot, and with value it is a count or a few characters. A mark carries no meaning for a screen reader unless label names it, such as "3 unread", so set label when the mark says something and leave it out when it only decorates.

Tone

2

<div class="flex items-center gap-6">
	{ui indicator, value: '2', tone: 'info', label: '2 updates'}
		{ui button, title: 'Updates', class: 'button-outline' /}
	{/ui}
	{ui indicator, value: 'New', tone: 'success'}
		{ui button, title: 'Library', class: 'button-outline' /}
	{/ui}
	{ui indicator, tone: 'warning', label: 'Needs attention'}
		{ui button, title: 'Orders', class: 'button-outline' /}
	{/ui}
</div>

tone is a theme color token: success, warning, info, primary, secondary or accent. The mark is destructive when it is left out, and its text takes the token's contrast color, so a count stays readable on any fill.

Position

AL GH

<div class="flex items-center gap-6">
	{ui indicator, tone: 'success', label: 'Online', class: '[--x:85%] [--y:85%]'}
		{ui avatar, initials: 'AL', class: 'text-2xl' /}
	{/ui}
	{ui indicator, tone: 'warning', label: 'Away', class: '[--x:0%] [--y:100%]'}
		{ui avatar, initials: 'GH', class: 'text-2xl' /}
	{/ui}
</div>

The mark is centred on a point of the content, the top end corner by default. --x and --y on the indicator move that point, as shares of the content's width and height: [--x:85%] [--y:85%] puts a presence dot on the lower edge of a round avatar, and [--x:0%] [--y:100%] puts it at the bottom start corner. They are ordinary utility classes, so they can change by breakpoint.

No mark


{var $unread = 0}
{ui indicator, value: (string) $unread, show: $unread > 0}
	{ui button, title: 'Inbox', class: 'button-outline' /}
{/ui}

show: false draws the content bare. That suits a count that is sometimes zero, where the mark should only appear when there is something to say.