Alert

theme
view
corners
title
message
import {Alert} from '@gravity-ui/uikit';

Theme

normal: Main theme (used by default).

info: Used for any kind of regular information.

success: Used for positive information.

warning: Used for information that needs attention.

danger: Used for critical errors.

utility: Used for useful tips.

clear: No styles, suitable for usage in other components (for example, as content in Popover)

NormalNormal theme
InfoInfo theme
SuccessSuccess theme
WarningWarning theme
DangerDanger theme
UtilityUtility theme
ClearClear theme
<Alert theme="normal" title="Normal" message="Normal theme" />
<Alert theme="info" title="Info" message="Info theme" />
<Alert theme="success" title="Success" message="Success theme" />
<Alert theme="warning" title="Warning" message="Warning theme" />
<Alert theme="danger" title="Danger" message="Danger theme" />
<Alert theme="utility" title="Utility" message="Utility theme" />
<Alert theme="clear" title="Clear" message="Clear theme" />

View

filled: Used to adjust the background color of the alert (used by default).

outlined: Used to adjust the border color of the alert.

FilledFilled view
OutlinedOutlined theme
<Alert title="Filled" message="Filled view" view="filled" />
<Alert title="Outlined" message="Outlined theme" view="outlined" />

Layout

vertical: Used to direct users to content if there is an actions property with buttons. It enables showing buttons below the text (used by default).

horizontal: Used to direct users to content if there is an actions property with buttons. It enables showing buttons to the right of the text.

VerticalVertical direction
HorizontalHorizontal direction
<Alert layout="vertical" title="Vertical" message="Vertical direction" actions={<Alert.Action>button</Alert.Action>} />
<Alert layout="horizontal" title="Horizontal" message="Horizontal direction" actions={<Alert.Action>button</Alert.Action>} />

Corners

rounded: Enables rounded corners of the alert window (used by default).

square: Enables squared corners of the alert window.

RoundedRounded corners
SquareSquare corners
<Alert title="Rounded" message="Rounded corners" corners="rounded"  />
<Alert title="Square" message="Square corners" corners="square" />

Alert title

title: Alert title. It has a lower priority than Alert.Title.

some text
<Alert title={<Alert.Title className={'some-class'} text="some text"></Alert.Title>} />

Alert message

message: Alert message. It should be meaningful enough to fully explain what the alert is about.

onClose

onClose: Callback function called when a user clicks the alert's close button. When this property is defined, the close button will visible.

Alert has closeAlert has close
<Alert onClose={() => alert('Close button pressed')} title="Alert has close" message="Alert has close" />

Align

Determines how the content inside the Alert component is vertically aligned.

baseline: Default alignment.

center: Content is vertically centered within the Alert component. It may be useful if actions take up more space than text, or if the icon must be in the middle of the content.

BaselineBaseline align
CenterCenter align
<Alert align="baseline" theme="info" title="Baseline" message="Baseline align" actions={<Alert.Action>button</Alert.Action>} />
<Alert align="center" theme="info" title="Center" message="Center align" actions={<Alert.Action>button</Alert.Action>} align="center"/>

Properties

NameDescriptionTypeDefault
themeAlert appearance"normal" "info" "success" "warning" "danger" "utility" "clear""normal"
viewEnable/disable background color of the alert"filled" "outlined""filled"
layoutUsed to direct users to content if there is property actions with buttons"vertical" "horizontal""vertical"
cornersUsed for round/square corners of the alert window"rounded" "square""rounded"
titleTitle of the alertstring
messageMessage of the alertReact.ReactNode
onCloseA callback function called when the user clicks the alert's close buttonFunction
actionsArray of buttons or full custom componentsReact.ReactNode "AlertAction"
alignDetermines how content inside the Alert component is vertically aligned"center" "baseline""baseline"
styleHTML style attributeReact.CSSProperties
classNameName of alert classstring
iconOverride default iconReact.ReactNode
qaHTML data-qa attribute, used in tests.string