Alert

Breaks the main user flow to present information.

Alert

To implement Alert component into your project you’ll need to add the import:

import Alert from "@kiwicom/orbit-components/lib/Alert";

After adding import into your project you can use it simply like:

<Alert>Hello World!</Alert>

Props

The table below contains all types of the props available in Alert component.

NameTypeDefaultDescription
childrenReact.NodeThe content of the Alert.
closablebooleanfalseIf true, the Close icon will be displayed. See Functional specs
dataTeststringOptional prop for testing purposes.
idstringSet id for Alert
iconReact.Element<any> \| booleanThe displayed icon. See Functional specs
inlineActionsReact.NodeRenders action to a right side of a Alert. See Functional specs
onClose() => void \| PromiseFunction for handling Alert onClose.
spaceAfterenumAdditional margin-bottom after component. See this docs
titleTranslationThe title of the Alert.
typeenum"info"The type of Alert.
suppressedbooleanIf suppressed is on, Alert will not have colored background
labelClosestringThe label of the close button.

enum

type
"info"
"success"
"warning"
"critical"

Functional specs

  • By passing the closable prop into Alert, you will be able to handle onClose function and Close icon will be displayed. Also, if you want to select the Close Button element for testing purposes, use [data-test=“AlertCloseButton”] selector.

  • When the Alert has a title prop, if you pass an icon prop as true, the Alert will have its own icon based on the selected type. If you want to use a different icon, just pass it to the icon prop as a React.Element. Alerts without a title or with a title but without an icon prop don’t have an icon.

  • Passing a inlineActions will cause children to be ignored. inlineActions should be used for displaying buttons inside short alerts which only have a title.

Subcomponents

AlertButton

To implement AlertButton component into your project you’ll need to add the import:

import AlertButton from "@kiwicom/orbit-components/lib/Alert/AlertButton";
// or
import { AlertButton } from "@kiwicom/orbit-components/lib/Alert";

After adding import into your project you can use it simply like:

<AlertButton type="info">Hello World!</AlertButton>

Props

Table below contains all types of the props available in AlertButton component.

NameTypeDefaultDescription
ariaControlsstringId of the element the button controls.
ariaExpandedbooleanTells screen reader the controlled element from ariaControls is expanded
asComponentstring \| React.Element"button"The component used for the root node.
fullWidthbooleanfalseIf true, the AlertButton grows to the full width of its container.
circledbooleanfalseIf true, the AlertButton is circular.
childrenReact.NodeThe content of the AlertButton.
dataTeststringOptional prop for testing purposes.
disabledbooleanfalseIf true, the AlertButton is disabled.
externalbooleanfalseIf true, the AlertButton opens link in a new tab.
hrefstringThe URL of the link to open when AlertButton is clicked.
iconLeftReact.NodeThe displayed icon on the left.
iconRightReact.NodeThe displayed icon on the right.
loadingbooleanfalseIf true, the loading glyph is displayed.
onClickevent => void \| PromiseFunction for handling onClick event.
reffuncProp for forwarded ref of the AlertButton.
rolestringSpecifies the role of an element.
spaceAfterenumAdditional margin-bottom after component. See this docs
submitbooleanfalseIf true, the Button has the type="submit" attribute, otherwise type="button".
tabIndexstring \| numberSpecifies the tab order of an element.
titlestringAdds aria-label.
typeenum"primary"The type of AlertButton.
widthstringThe width of the AlertButton. Can be any string - 100px, 20%.

Button enum

type
"info"
"success"
"warning"
"critical"
"infoSubtle"
"successSubtle"
"warningSubtle"
"criticalSubtle"