Components

Alert

Source
Highlight important status, guidance, or feedback.
Install with the CLI
npx @vyui/cli add alert

Overview

VyAlert displays a title, description, leading icon, actions, and an optional close control. Semantic color and visual variants make it suitable for informational, success, warning, and error messages.

Usage

Actions and dismissal

orientation="vertical" places actions below the copy. Horizontal orientation places them at the trailing edge.

The alert does not manage or hide itself. When the close control is tapped it emits update:open(false); the parent decides whether to remove it.

Variants

Combine semantic colors with solid, soft, outline, subtle, or ghost.

Features and behavior

  • Slot content takes precedence over title and description props.
  • The close icon resolves from closeIcon, then appConfig.ui.icons.close, then i-lucide-x.
  • In vertical orientation, actions render below the title and description.
  • In horizontal orientation, actions and the close control share the trailing actions region.
  • The description receives additional top spacing only when a title prop or title slot is present.

Props

PropTypeDefaultDescription
titlestringundefinedTitle text, replaced by the title slot.
descriptionstringundefinedSupporting text, replaced by the description slot.
iconstringundefinedLeading Iconify icon name.
colorColor'primary'Semantic color.
variant'solid' | 'outline' | 'subtle' | 'soft' | 'ghost''solid'Surface and foreground treatment.
orientation'horizontal' | 'vertical''vertical'Position of actions relative to content.
closebooleanfalseShows the built-in close control.
closeIconstringApp icon / i-lucide-xIconify name for the close control.
classanyundefinedClasses merged onto the root.
uiPartial<Record<AlertSlot, any>>undefinedPer-instance theme slot overrides.

Color defaults to primary, secondary, success, info, warning, error, or neutral, and supports consumer registry extensions.

Emits

EventPayloadDescription
update:openfalseEmitted when the built-in close control is tapped.

Slots

SlotPropsDescription
leading{ iconColor: string }Replaces the leading icon.
titleReplaces title text.
descriptionReplaces description text.
actionsAction controls, positioned by orientation.
close{ iconColor: string }Replaces the close region.

Styling and theming

Override globally through appConfig.ui.alert or locally with ui.

UI slotPurpose
rootAlert surface and orientation layout.
wrapperTitle and description column.
titleTitle text.
descriptionSupporting text.
iconLeading and built-in close icons.
actionsActions and close-control region.
closeBuilt-in close hit area.

The theme combines color, variant, orientation, and an internal title state. solid uses a filled semantic surface with white foreground; outline, subtle, soft, and ghost progressively reduce surface emphasis.

Accessibility

Use a concise title and put additional detail in the description. Alerts are visually prominent but the wrapper does not currently add an assertive live-region announcement, so critical time-sensitive messaging may need application-level announcement handling.

The built-in close region is currently a tappable Lynx view without an explicit button role or accessibility label. For an accessible dismiss action, replace the close slot with a labeled control in your application.

Platform notes

  • The component renders Lynx view and text elements.
  • SVG glyphs cannot inherit currentColor in Lynx, so iconColor is resolved to an explicit hex value and passed to built-in icons and custom icon slots.
  • The default theme uses vyui's semantic surface/text/border tokens, so it adapts automatically under dark mode (see Theming → Dark Mode).
  • ActionSheet for choosing an action.
  • Toast for transient feedback.
  • Banner for page-wide announcements.