Inline alert
Inline alert in four tones with a pixel icon and a glowing stripe; dismissing scatters the stripe and collapses the alert.
Playground
Change a prop and the component re-renders. Props marked remounts set an initial value, so the component starts over.
<PxAlert type="warning" heading="Usage at 85%" dismissible>You’ve used most of this week’s limit.</PxAlert>
Installation
pnpm dlx shadcn@latest add @lumesec/px-alertFirst timeRegister the @lumesec registry once, or install by URL+
Adds @lumesec to your components.json:
pnpm dlx shadcn@latest registry add @lumesec=https://elements.lumesec.ai/r/{name}.jsonOr skip the setup and install by URL:
npx shadcn@latest add https://elements.lumesec.ai/r/px-alert.jsonUsage
import { PxAlert } from "@/components/lumesec/px-alert";
export function Example() {
return (
<PxAlert type="warning" heading="Usage at 85%" dismissible>
You’ve used most of this week’s limit.
</PxAlert>
);
}Behaviour
Info, success, warning and error, each with a pixel icon and a glowing stripe. Dismissing scatters the stripe and collapses the alert.
API reference
Props
Also accepts every prop of <div> (React.ComponentProps<"div">), spread onto the root element.
openTypebooleanControlled visibility. Use with onOpenChange; turning it off plays the dismiss animation before the alert hides.
defaultOpenTypebooleanDefaulttrueInitial visibility when uncontrolled.
typeType"info" | "success" | "warning" | "error"Default"info"Colour, icon and ARIA role.
headingTypeReact.ReactNodeBold title above the message; left out when empty.
childrenTypeReact.ReactNodeThe message.
dismissibleTypebooleanDefaultfalseShows a dismiss button.
onOpenChangeType(open: boolean) => voidCalled with false when the dismiss button is pressed.
Ref
ref points at the root HTMLDivElement.
Accessibility
errorandwarningalerts haverole="alert";infoandsuccessalerts haverole="status".- The dismiss button is a native button labelled "Dismiss".
- The icon and stripe are drawn on an
aria-hiddencanvas; the tone is not conveyed as text. - Once dismissed the root is
hiddenand leaves the accessibility tree. - Reduced motion: the stripe glow stops, and dismissing hides the alert at once without scattering pixels.
Theming
Styled with Tailwind classes on your shadcn theme tokens, so light and dark follow your theme. The accent comes from --lumesec. See Theming.
This component reads --lumesec, --lumesec-shine, --lumesec-success, --lumesec-warning, --destructive, --border, --card, --foreground and --muted-foreground.
Notes
- Uncontrolled alerts stay hidden after dismissal; control
opento show one again. - The root carries
data-state="open"ordata-state="closed"anddata-type.
Related
Was this page helpful?