Indicator
Display a badge at the corner of another element.
#
Documentation
#
#
Usage
#
import { Button, Indicator } from "@optiaxiom/react";
import { IconBell } from "@tabler/icons-react";
export function App() {
return (
<Indicator intent="danger" variant="strong">
<Button aria-label="Notifications" icon={<IconBell />} />
</Indicator>
);
}#
Content
#
Use the content prop to set the content of the badge.
import { Button, Indicator } from "@optiaxiom/react";
import { IconBell } from "@tabler/icons-react";
export function App() {
return (
<Indicator content="4" intent="danger" variant="strong">
<Button aria-label="Notifications" icon={<IconBell />} />
</Indicator>
);
}#
Appearance
#
Use the intent and variant props to fine tune the appearance of the badge.
"use client";
import type { ComponentPropsWithRef } from "react";
import { Button, Indicator } from "@optiaxiom/react";
import { IconBell } from "@tabler/icons-react";
export function App({
intent = "success",
variant = "subtle",
}: Pick<ComponentPropsWithRef<typeof Indicator>, "intent" | "variant">) {
return (
<Indicator content="4" intent={intent} variant={variant}>
<Button aria-label="Notifications" icon={<IconBell />} />
</Indicator>
);
}#
Hide indicator
#
Use the disabled prop to hide the badge.
"use client";
import type { ComponentPropsWithRef } from "react";
import { Button, Indicator } from "@optiaxiom/react";
import { IconBell } from "@tabler/icons-react";
export function App({
disabled = false,
}: Pick<ComponentPropsWithRef<typeof Indicator>, "disabled">) {
return (
<Indicator content="4" disabled={disabled} intent="danger">
<Button aria-label="Notifications" icon={<IconBell />} />
</Indicator>
);
}#
Props
#
#
Indicator
#
Supports all Box props in addition to its own. Renders a <div> element.
Prop |
|---|
asChildChange the default rendered element for the one passed as a child, merging their props and behavior. Read the Composition guide for more details.
|
className
|
contentSet the content of the badge.
|
disabledWhether to show or hide badge.
|
intentControl the appearance by selecting between the different badge types.
|
lineClampTruncate the text at specific number of lines.
|
offsetWhether to offset the badge and display slightly outside the content box.
Default: |
pingWhether to show a ping animation for the badge.
|
positionSet which corner the badge is displayed.
Default: |
truncateWhether to truncate the text and add an ellipsis at the end.
|
variantControl the style of the badge.
|
#
Changelog
#
#
0.1.0
#
- Added component