Indicator
A indicator-badges is a small, visual element or indicator used in user interface design. They serve various purposes, including highlighting new or unread content, indicating the number of notifications.
Basic
Absolute positioning
- Indicator will be positioned
absoluteif Indicator have children element.
99
Source Code
import { NotificationOutline } from '@ocean-network-express/magenta-ui/icons';
import { Avatar, IconButton, Indicator } from '@ocean-network-express/magenta-ui/react';
import React from 'react';
export function AbsolutePositioning() {
return (
<div className={'flex gap-20'}>
<Indicator>
<IconButton variant={'outline'} color={'neutral'} size={'lg'}>
<NotificationOutline />
</IconButton>
</Indicator>Standalone
- Indicator will be positioned
initialif Indicator do not have children element.
99
Source Code
import { Indicator } from '@ocean-network-express/magenta-ui/react';
import React from 'react';
export function Standalone() {
return (
<div className="flex gap-20">
<Indicator />
<Indicator label={'99'} />
</div>
);
}Variants
- Button supports 2 variants:
lightandbold. - Default variant is
light.
99
99
99
99
Source Code
import { NotificationOutline } from '@ocean-network-express/magenta-ui/icons';
import { Divider, IconButton, Indicator } from '@ocean-network-express/magenta-ui/react';
import React from 'react';
export function Variants() {
return (
<div style={{ display: 'flex', gap: '24px', flexDirection: 'column' }}>
<div className="flex gap-20">
<Indicator variant={'light'} label={'99'}>
<IconButton variant={'outline'} color={'neutral'}>
<NotificationOutline />
</IconButton>Offset
- Set
offsetto change indicator position. It is useful when Indicator component is used with children that have border-radius.
Source Code
import { NotificationOutline } from '@ocean-network-express/magenta-ui/icons';
import { Avatar, IconButton, Indicator } from '@ocean-network-express/magenta-ui/react';
import React from 'react';
export function Offset() {
return (
<div className="flex gap-20">
<Indicator offset={2}>
<IconButton color={'neutral'} size={'lg'}>
<NotificationOutline />
</IconButton>
</Indicator>Sizes
- Indicator supports 4 sizes
xs,sm,mdandlgand can be changed by passing thesizeprop. - Default size is
lg. - When using
xssize, Label WILL NOT rendered inside the indicator.
99
99
99
99
99
99
Source Code
import { NotificationOutline } from '@ocean-network-express/magenta-ui/icons';
import { Divider, IconButton, Indicator } from '@ocean-network-express/magenta-ui/react';
import React from 'react';
export function Sizes() {
return (
<div style={{ display: 'flex', gap: '24px', flexDirection: 'column' }}>
<div className="flex gap-20">
<Indicator label={'99'} size={'lg'}>
<IconButton>
<NotificationOutline />
</IconButton>Customize
Indicator in Tabs
Source Code
import {
TrainFrontOutline,
TruckFrontOutline,
VesselFrontOutline,
} from '@ocean-network-express/magenta-ui/icons';
import {
Indicator,
TabHeader,
TabList,
TabListItem,
TabPanel,
TabPanels,Indicator in Segmented control
Source Code
import { Indicator, Segmented, SegmentedItem } from '@ocean-network-express/magenta-ui/react';
import React from 'react';
export function CustomizeSegmented() {
return (
<Segmented>
<SegmentedItem>
All <Indicator label={'23'} />
</SegmentedItem>
<SegmentedItem>Unread</SegmentedItem>
<SegmentedItem>
Starred <Indicator label={'12'} />Badge
Text Only
- Set
texttotrueto display a text-only badge using thelabelprop. - By default, the
textprop isfalse.
Light:
Label
Label
Label
Label
Label
Label
Label
Label
Label
Bold:
Label
Label
Label
Label
Label
Label
Label
Label
Label
Source Code
import { Divider, Indicator, IndicatorProps, Text } from '@ocean-network-express/magenta-ui/react';
import React from 'react';
const listColorLabels: IndicatorProps['color'][] = [
'neutral',
'primary',
'secondary',
'blue',
'green',
'orange',
'red',
'purple',Icon and Text
- You can pass any icon from
@ocean-network-express/magenta-ui/icons(or any otherReactNode) to theleftIconorrightIconprop to display an icon alongside thelabel. - The
leftIconandrightIconprops are only rendered when thetextprop is set totrue.
Light:
Label
Label
Label
Label
Label
Label
Label
Label
Label
Bold:
Label
Label
Label
Label
Label
Label
Label
Label
Label
Source Code
import { VesselFrontOutline } from '@ocean-network-express/magenta-ui/icons';
import { Divider, Indicator, IndicatorProps, Text } from '@ocean-network-express/magenta-ui/react';
import React from 'react';
const listColorLabels: IndicatorProps['color'][] = [
'neutral',
'primary',
'secondary',
'blue',
'green',
'orange',
'red',Was this page helpful?
Badge
Status
Notification
Indicator - Examples