Skip to main content

Alert

Communicate a state that affects the entire system, not just a feature or page. It persists over a session and appears without the user initiating the action.

github
View source code
import { Alert } from '@uhg-abyss/mobile';
    () => {
    return (
    <Alert
    heading="Completed Health Screen:"
    paragraph="Review of your results are ready."
    isCloseable={true}
    >
    <Alert.Button>Go To Results</Alert.Button>
    </Alert>
    );
    };

    Heading and Paragraph​

    The heading and paragraph props are used to set the heading and paragraph of the alert. Both props are required.

    isCloseable​

    The isCloseable prop determines if a close button is displayed in the alert. It defaults to true unless the inline prop is enabled.

    Variants​

    Use the variant property to set the color of the Alert. The options are success, warning, error, and info. The default is success.

    Inline Variant​

    The inline variant functions the same as the default, but is rounder and takes up less width. It uses the inline prop, changing the border radius to create a more rounded look. The inline variant should be wrapped in a component that provides padding on the left and right (see example below).

    Children​

    Add Children to the Alert component by simply placing elements between the Alert tags. Children should be used for adding either a link or button. Links and buttons can be added with the Alert.Link and Alert.Button components, respectively.

    Change Icon​

    Use the icon property to pass in a specific Icon component.

    Since heading and paragraph are required props, icons are used in a setting in which it is just a decorative element (which is the default case for icons) and should be ignored by screen readers. The implementation below provides an example. Since the default of isScreenReadable is set to false, no specific changes need to be made for decorative icons. Find further guidance on icons symbols in the Icons Symbols Tab.

    onClose​

    Use the onClose property to handle the action when close button is triggered. The onClose property is always required.

    Alert Props​

    Name
    Type
    DefaultRequiredA11yDescription
    children
    string | number | boolean | ReactElement<any, string | JSXElementConstructor<any>> | Iterable<ReactNode> | ReactPortal | null | undefined
    The contents of the Alert component
    heading
    string
    Sets the heading for the alert
    headingAccessibilityRole
    AccessibilityRole | undefined
    'header'
    Accessibility role for the heading
    icon
    string | number | boolean | ReactElement<any, string | JSXElementConstructor<any>> | Iterable<ReactNode> | ReactPortal | null | undefined
    Change the default icon
    inline
    boolean | undefined
    false
    Change the alert type to inline
    isCloseable
    boolean | undefined
    Determines if alert has close button
    isVisible
    boolean | undefined
    true
    Flag to show or hide Alert
    onClose
    GestureResponderEventHandler
    Callback fired when the alert is closed
    paragraph
    string
    Sets the paragraph for the alert
    variant
    AlertVariant | undefined
    'success'
    Change the alert style

    Name
    Type
    DefaultDescription
    after
    Element | LinkInsertFunction | undefined
    Insert element into link component after children
    alt
    boolean | undefined
    false
    Set the color of the Link to the alt variant
    before
    Element | LinkInsertFunction | undefined
    Insert element into link component before children
    children
    ((string | number | boolean | Value | AnimatedInterpolation<string | number> | ((state: PressableStateCallbackType) => ReactNode) | WithAnimatedObject<...> | WithAnimatedObject<...> | WithAnimatedObject<...> | null) & string) | undefined
    Either children or a render prop that receives a boolean reflecting whether
    the component is currently pressed.
    Set the text of the link
    color
    Color | undefined
    Set the color of the link
    href
    string | undefined
    Set the URL of the link
    inline
    false | undefined
    false
    Render as standard Pressable link with flexbox layout.
    Supports before/after icons. Use inline={true} for text-inline variant.
    onPress
    (((event: GestureResponderEvent) => void) & ((event: GestureResponderEvent) => void)) | null | undefined
    Called when a single tap gesture is detected.
    Callback fired when the link is pressed
    onPressIn
    (((event: GestureResponderEvent) => void) & ((event: GestureResponderEvent) => void)) | null | undefined
    Called when a touch is engaged before onPress.
    Callback fired when the link is pressed In
    onPressOut
    (((event: GestureResponderEvent) => void) & ((event: GestureResponderEvent) => void)) | null | undefined
    Called when a touch is released before onPress.
    Callback fired when the link is pressed Out
    underline
    boolean | undefined
    Used to underline the link text

    Alert.Button Props​

    Name
    Type
    DefaultDescription
    children
    ReactNode | ((state: PressableStateCallbackType) => ReactNode)
    The contents of the button component
    icon
    ButtonIcon
    Defines the icon name, variant and position
    iconPosition
    "leading" | "trailing" | "iconOnly" | undefined
    'trailing'
    Defines the position of the icon relative to the button text
    isDisabled
    boolean | undefined
    false
    Disables the button
    isLoading
    boolean | undefined
    false
    Shows a loading spinner
    onPress
    GestureResponderEventHandler
    Callback fired when the Button is pressed
    submit
    boolean | undefined
    false
    Flag to indicate the button is a form submit button
    type
    "text" | "filled" | "outline" | undefined
    'filled'
    Defines the button type (style)

    Alert Classes​

    Class NameDescription
    abyss-alert-children-containerAlert children container
    abyss-alert-close-buttonAlert close icon container
    abyss-alert-close-iconAlert close icon element
    abyss-alert-contentAlert content element
    abyss-alert-headingAlert heading element
    abyss-alert-iconAlert icon element
    abyss-alert-paragraphAlert paragraph element
    abyss-alert-rootAlert root element

    Class NameDescription
    abyss-alert-link-rootAlert link element
    abyss-link-iconLink icon
    abyss-link-labelLink label
    abyss-link-rootLink root element

    Alert.Button Classes​

    Class NameDescription
    abyss-alert-button-rootAlert button element
    abyss-button-iconButton icon element
    abyss-button-labelButton label element
    abyss-button-loading-spinnerButton loading spinner element
    abyss-button-rootButton root element

    Alert Tokens​

    Token NameValue
    alert.color.surface.container.success
    #F0F9ED
    alert.color.surface.container.warning
    #FFFBEB
    alert.color.surface.container.info
    #EDF3FB
    alert.color.surface.container.error
    #FCF0F0
    alert.color.icon.success
    #007000
    alert.color.icon.warning
    #C24E14
    alert.color.icon.info
    #196ECF
    alert.color.icon.error
    #990000
    alert.color.icon.close
    #4B4D4F
    alert.color.text.heading
    #323334
    alert.color.text.paragraph
    #4B4D4F
    alert.color.border.container.success
    #BFDBBF
    alert.color.border.container.warning
    #F3D8C0
    alert.color.border.container.info
    #C3D8F2
    alert.color.border.container.error
    #E8C0C0
    alert.border-radius.all.container.inline
    8
    alert.border-width.bottom.container.full-width
    1
    alert.border-width.bottom.container.inline
    1
    alert.border-width.all.container.inline
    1
    alert.sizing.all.icon.close
    20
    alert.sizing.all.icon.leading
    20
    alert.spacing.padding.all.container
    16
    alert.spacing.gap.vertical.text
    2
    alert.spacing.gap.vertical.content
    8
    alert.spacing.gap.horizontal.container
    8

    Alert Props​

    V2V1Status
    childrenchildrenUnchanged
    headingtitleRenamed
    iconiconUnchanged
    inlineinlineUnchanged
    isCloseableisCloseableUnchanged
    isVisibleisVisibleUnchanged
    onCloseonCloseUnchanged
    paragraphdescriptionRenamed
    variantvariantUnchanged

    Alert Classes​

    V2V1Status
    alert-children-containeralert-children-containerUnchanged
    alert-close-buttonalert-close-buttonUnchanged
    alert-close-iconalert-close-iconUnchanged
    alert-contentalert-contentUnchanged
    alert-headingalert-titleRenamed
    alert-iconalert-iconUnchanged
    alert-paragraphalert-textRenamed
    alert-rootalert-rootUnchanged
    Table of Contents