No Preview

Sorry, but you either have no stories or none are selected somehow.

If the problem persists, check the browser console, or the terminal you've run Storybook from.

Alert

An alert is a modal dialog that interrupts the user's workflow to communicate an important message and acquire a response.

usage
import { Alert, Heading, Content, useAlertTriggerContext } from "@sharegate/orbit-ui";
sources
Github

Guidelines

When to use

  • To display a confirmation message, an error, or a warning.

Accessibility

Announcement

  • aria-label and aria-describedby defaults to the alert <Heading> and <Content> values.
  • You can overwrite them by setting aria-label and aria-describedby props on the alert.

Focus

  • If the alert calls for an action, make sure to set the focus correctly to avoid any unwanted action.
  • You can use the autoFocusButton prop on the alert to specify which control should have the initial focus.
  • If your alert is destructive, you can offer a secondary button Cancel and set the focus to the secondary button with autoFocusButton="secondary".

Usage

Default

An alert must have an heading, some content and a primary button label.

Editable example

Secondary button

An alert can have a secondary button.

Editable example

Cancel button

An alert can have a cancel button.

Editable example

Disabled buttons

An alert primary and secondary buttons can be disabled.

Editable example

Confirmation

Use a confirmation alert when a non destructive action is required from a user.

Editable example

Destructive

Use a destructive alert to confirm a permanent change, like deleting data.

Editable example

Warning

Use a warning alert to inform of a significant change.

Editable example

Negative

Use a negative alert to inform that something went wrong, like a server error.

Editable example

Controlled

The open state can be handled in controlled mode.

Editable example

API

Alert

usage
import { Alert } from "@sharegate/orbit-ui";
slots
"heading", "content"
NameDescriptionDefault
autoFocusButton
The button to focus by default when the alert open.
"primary""secondary""cancel"
-
cancelButtonLabel
The cancel button label.
string
-
onCancelButtonClick
Called when the cancel button is clicked.
(event: MouseEvent<Element, MouseEvent>) => void
eventReact's original event.
-
onClose
Called when a closing event happenened.
(event: SyntheticEvent<Element, Event>) => void
eventReact's original synthetic event.
-
onPrimaryButtonClick
Called when the primary button is clicked.
(event: MouseEvent<Element, MouseEvent>) => void
eventReact's original event.
-
onSecondaryButtonClick
Called when the secondary button is clicked.
(event: MouseEvent<Element, MouseEvent>) => void
eventReact's original event.
-
primaryButtonDisabled
Whether or not the primary button is disabled.
falsetrue
-
primaryButtonLabel*
The primary button label.
string
-
secondaryButtonDisabled
Whether or not the secondary button is disabled.
falsetrue
-
secondaryButtonLabel
The secondary button label.
string
-
variant
The style to use.
"warning""negative""confirmation""destructive"
"confirmation"
wrapperProps
Additional props to render on the wrapper element.
Partial<OmitInternalProps<InnerBoxProps, never> & RefAttributes<any>>
-
zIndex
The z-index of the dialog.
number
1

Heading

usage
import { Heading } from "@sharegate/orbit-ui";
NameDescriptionDefault
size
An heading can vary in size.
"xs" | "sm" | "md" | "lg" | "xl" | "2xs" | ResponsiveValue<"xs" | "sm" | "md" | "lg" | "xl" | "2xs">
-
slot
Slot to render into.
string
-

Content

usage
import { Content } from "@sharegate/orbit-ui";
NameDescriptionDefault
children*
React children.
string | number | false | true | ReactElement<any, string | JSXElementConstructor<any>> | ReactFragment | ReactPortal
-
slot
Slot to render into.
string
-