Inline Alert

InlineAlert presents persistent, in-context feedback inside the current layout.

New billing cycleInvoices are now issued on the 1st.
tsx
import { InlineAlert } from '@/components/ui/wideset/inline-alert/InlineAlert';

<InlineAlert
  title="New billing cycle"
  message="Invoices are now issued on the 1st."
>
  <InlineAlert.Action>Details</InlineAlert.Action>
</InlineAlert>

Installation

pnpm dlx wideset add inline-alert

Copies the component and any Wideset components it uses into your project.

Examples

Statuses

Pick the status by what the user has to do: error when something must be fixed, warning before a risky step, success to confirm a finished task, info for neutral guidance. error gets role="alert" and is read out at once; the other statuses are role="status", read when the screen reader is idle. Place the alert next to the section it is about, not at the top of the page.

tsx
import { InlineAlert } from '@/components/ui/wideset/inline-alert/InlineAlert';

const alerts = [
  {
    status: 'error',
    title: 'Publishing failed',
    message: 'We could not publish your changes. Check the required fields and try again.',
    action: 'Retry',
  },
  {
    status: 'warning',
    title: 'Review before publishing',
    message: 'This update affects 12 records. Confirm the details before you continue.',
    action: 'Review',
  },
  {
    status: 'success',
    title: 'Changes saved',
    message: 'Your workspace was updated and is ready to share.',
    action: 'Open',
  },
  {
    status: 'info',
    title: 'New comments',
    message: 'A teammate left comments on this file. Review them before the next handoff.',
    action: 'View',
  },
] as const;

export default function InlineAlertStatuses() {
  return (
    <div className="gap-ws-12 flex flex-col">
      {alerts.map(({ status, title, message, action }) => (
        <InlineAlert key={status} status={status} title={title} message={message}>
          <InlineAlert.Action>{action}</InlineAlert.Action>
        </InlineAlert>
      ))}
    </div>
  );
}

Orientation

horizontal keeps the message and its actions on one row, which fits a short message in a wide section. vertical puts the actions under the message: use it for longer copy, more than one action, or a narrow column such as a side panel, where a single row would squeeze the text.

tsx
import { InlineAlert } from '@/components/ui/wideset/inline-alert/InlineAlert';

export default function InlineAlertOrientation() {
  return (
    <div className="gap-ws-12 flex flex-col">
      <InlineAlert
        status="info"
        orientation="horizontal"
        title="New billing cycle"
        message="Invoices are now issued on the 1st."
      >
        <InlineAlert.Action>Details</InlineAlert.Action>
      </InlineAlert>
      <InlineAlert
        status="info"
        orientation="vertical"
        title="New billing cycle"
        message="Invoices are now issued on the 1st of each month. Payments already scheduled for this month keep their original date."
      >
        <InlineAlert.Action>Details</InlineAlert.Action>
        <InlineAlert.Action preset="ghost">Billing settings</InlineAlert.Action>
      </InlineAlert>
    </div>
  );
}

Persistent

By default an alert can be closed, and stays closed until its alertId or messageId changes. Make it persistent when the condition still holds and closing it would only hide the problem, such as a failed payment; let the user dismiss messages that are only informative. Control it with dismissed and onDismiss when the closed state must survive a reload.

tsx
import { InlineAlert } from '@/components/ui/wideset/inline-alert/InlineAlert';

export default function InlineAlertPersistent() {
  return (
    <div className="gap-ws-5 flex w-[30rem] max-w-full flex-col">
      <InlineAlert status="info" message="Invoices are now issued on the 1st." />
      <InlineAlert status="error" persistent message="Your card was declined.">
        <InlineAlert.Action>Update card</InlineAlert.Action>
      </InlineAlert>
    </div>
  );
}

API reference

InlineAlert

NameDescriptionDefault
alertId

Optional identifier used to reset uncontrolled dismissed state when the alert instance changes.

string
—
children

Alert content, typically composed with `InlineAlert.Title`, `InlineAlert.Message`, and `InlineAlert.Action`. Slot content overrides the `title` and `message` props.

ReactNode
—
className

Additional CSS classes merged with the alert root element.

string
—
dismissAriaLabel

Accessible label for the dismiss button. Defaults to `'Dismiss'`.

string
'Dismiss'
dismissed

Controlled visibility state. When `true`, the alert is hidden.

boolean
—
message

Main alert message when not using `InlineAlert.Message`.

ReactNode
—
messageId

Optional identifier used to reset uncontrolled dismissed state when the message content changes.

string
—
onDismiss

Called when the user presses the dismiss button.

(() => void)
—
orientation
'horizontal''vertical'
'horizontal'
persistent

When `true`, the dismiss button is not rendered.

boolean
false
status
'success''error''warning''info'
'info'
title

Optional short title rendered above or before the main message.

string
—
Every other prop of <div> is passed through to it. See MDN: <div>.

InlineAlert.Action

NameDescriptionDefault
asChild

Whether to render the button styling onto its child element via Radix Slot.

boolean
—
children

Button label or custom content rendered inside the root.

ReactNode
—
className

Additional CSS classes merged with the button root.

string
—
defaultMotion

Turns the component's built-in animations on or off. When omitted, inherits the value from the nearest `MotionProvider`.

boolean
true
disabled

Disables the button visually and functionally.

boolean
—
onClick

Called when the user activates the button.

MouseEventHandler<HTMLButtonElement>
—
preset
'border''filled''ghost'
'border'
size
'xs''sm''md''lg'
'sm'
type

Native button type used for form behavior.

'button''submit''reset'
—
variant
'primary''secondary''danger''success''inverse'
'secondary'

InlineAlert.Message

NameDescriptionDefault
children*

Main inline message content.

ReactNode
—

InlineAlert.Outlet

NameDescriptionDefault
className

Additional CSS classes merged with the outlet container.

string
—
inlineAlertClassName

Additional CSS classes merged with each rendered inline alert root.

string
—
messageClassName

Additional CSS classes merged with each rendered inline alert message.

string
—
Every other prop of <div> is passed through to it. See MDN: <div>.

InlineAlert.Title

NameDescriptionDefault
children*

Short heading content rendered above or before the alert message.

ReactNode
—

Accessibility

  • error renders role="alert" (read at once); the other statuses render role="status" (read when idle).
  • The icon is decorative; the text must carry the meaning, not the colour.
  • dismissAriaLabel names the close button (default 'Dismiss').
PartRendersDescription
InlineAlert<div>Persistent feedback within a page section.
InlineAlert.Action—Props forwarded to `InlineAlert.Action`. Inherits the full `Button` API and defaults to `preset="border"`, `variant="secondary"`, and `size="sm"` when those props are not provided.
InlineAlert.Message—The message displayed inside the feedback surface.
InlineAlert.Outlet<div>Container for alerts shown through its ref (`show`, `dismiss`, `dismissAll`).
InlineAlert.Title—The primary title text.
New billing cycleInvoices are now issued on the 1st.
tsx
import { InlineAlert } from '@/components/ui/wideset/inline-alert/InlineAlert';

<InlineAlert
  title="New billing cycle"
  message="Invoices are now issued on the 1st."
>
  <InlineAlert.Action>Details</InlineAlert.Action>
</InlineAlert>

Appearance

Status
Orientation

Content

Title
Action

State

Persistent