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.

Submit feedback
github
import { Alert } from '@uhg-abyss/mobile';
    <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

    Prop NameTypeDefaultDescription
    childrennode-The contents of the Alert component
    headingstring-Sets the heading for the alert
    iconReactNode-Change the default icon
    inlinebooleanfalseChange the alert type to inline
    isCloseablebooleantrueDetermines if alert has close button
    isVisiblebooleantrueFlag to show or hide Alert
    onClosefunction-Callback fired when the alert is closed
    paragraphstring-Sets the paragraph for the alert
    variant'info' | 'success' | 'error' | 'warning'successChange the alert style

    Alert.Link Props

    Prop NameTypeDefaultDescription
    afterReactNode-Insert element into link component after children
    beforeReactNode-Insert element into link component before children
    childrenReactNode-Set the text of the link
    colorstring-Set the color of the link
    hrefstring-Set the URL of the link
    onPressfunction-Callback fired when the button is pressed
    underlinebooleanfalseUsed to underline the link text

    Alert.Button Props

    Prop NameTypeDefaultDescription
    afternode-Insert element into button component after children
    beforenode-Insert element into button component before children
    childrennode-The contents of the button component
    isDisabledboolean-Flag to disable the button
    onPressfunction-Callback fired when the button is pressed
    roundedboolean-Flag to make button rounded

    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

    Alert.Link Classes

    Class NameDescription
    abyss-alert-link-rootAlert link element

    Alert.Button Classes

    Class NameDescription
    abyss-alert-button-rootAlert link 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