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.
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.
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 |
---|
asChild Change the default rendered element for the one passed as a child, merging their props and behavior. Read the Composition guide for more details.
|
className
|
content Set the content of the badge.
|
disabled Whether to show or hide badge.
|
intent Control the appearance by selecting between the different badge types.
|
lineClamp Truncate the text at specific number of lines.
|
offset Whether to offset the badge and display slightly outside the content box.
Default: |
ping Whether to show a ping animation for the badge.
|
position Set which corner the badge is displayed.
Default: |
truncate Whether to truncate the text and add an ellipsis at the end.
|
variant Control the style of the badge.
|
#
Changelog
#
#
0.1.0
#
- Added component