Alert

The Alert component is a customizable component that allows to grab user attention and communicate an important message (like network event, app state errors or notifications, user account messages etc).

It does not require user input. If such interaction is needed, then AlertDialog (WIP) must be used instead.

Alert could be closable. It emits close event when user clicks on the close button. It is up to the you to decide what to do with it.

Note that this component is not suppose to be used inside markdown files. If you want just to display a warning or note regarding your docs to the user, consider to use Callout instead.

Types

Alert has such contextual types: success, info, warning, and danger. It also has additional neutral, primary and secondary types.

This is closable primary alert with custom icon, code, a link and code link.
This is closable secondary alert with custom icon, code, a link and code link.
This is closable neutral alert with emoji as an icon, code, a link and code link.
This is closable info alert with icon, code, a link and code link.
This is closable success alert with icon, code, a link and code link.
This is closable warning alert with icon, code, a link and code link.
This is closable danger alert with icon, code, a link and code link.
MDC
::alert{type="info" closable icon}
This is closable **info** alert with `icon`, `code`, a [link](/) and [`code` link](/).
::

::alert{type="success" closable icon}
This is closable **success** alert with `icon`, `code`, a [link](/) and [`code` link](/).
::

::alert{type="warning" closable icon}
This is closable **warning** alert with `icon`, `code`, a [link](/) and [`code` link](/).
::

::alert{type="danger" closable icon}
This is closable **danger** alert with `icon`, `code`, a [link](/) and [`code` link](/).
::

::alert{type="neutral" closable icon}
This is closable **neutral** alert with emoji as an `icon`, `code`, a [link](/) and [`code` link](/).
::

::alert{type="primary" closable icon}
This is closable **primary** alert with custom `icon`, `code`, a [link](/) and [`code` link](/).
::

Icon

Alert could have an icon, which is displayed on the left side of the alert. By default, it is the pre-selected icon that corresponds to the type prop, but it could be overridden using icon prop. Any component name prefixed with Icon, icon name from Iconify or any emoji could be used.

This is closable neutral alert without icon, code, a link and code link.
๐Ÿš€This is closable neutral alert with emoji as an icon, code, a link and code link.
This is closable primary alert with custom icon, code, a link and code link.
MDC
::alert{type="success" closable}
This is closable **neutral** alert without `icon`, `code`, a [link](/) and [`code` link](/).
::

::alert{type="neutral" closable icon="๐Ÿš€"}
This is closable **neutral** alert with emoji as an `icon`, `code`, a [link](/) and [`code` link](/).
::

::alert{type="primary" closable icon="simple-icons:nuxtdotjs"}
This is closable **primary** alert with custom `icon`, `code`, a [link](/) and [`code` link](/).
::

Props

PropsTypeDefaultDescription
typeStringneutralContextual type of Alert. Possible values are: success, info, warning, danger, primary, secondary and neutral
closableBooleanfalseWhether Alert is closable or not
iconString, BooleanfalseIcon to be displayed on the left side of the alert. Any component name prefixed with Icon, icon name from Iconify or any emoji could be used.

Slots

SlotDescription
defaultDefault slot renders inside Alert

Events

EventDescription
closeEmitted when user clicks on the close button

Design Tokens

tokens.config.ts
import { defineTheme } from 'pinceau'

export default defineTheme({
  elements: {
    alert: {
      width: '100%',
      paddingX: '{space.4}',
      paddingY: '{space.4}',
      borderRadius: '{elements.radii.base}',
      borderWidth: '1px',
      borderStyle: 'solid',
      boxShadow: 'inset 0.25px 0.5px 0px hsla(0,0%,100%,.1), inset -0.25px 0px 0px hsla(0,0%,100%,.1)',
      icon: {
        width: '{space.6}',
        height: '{space.6}',
        marginInlineEnd: '{space.3}'
      },
      closeButton: {
        padding: '{space.1}',
        marginInlineStart: '{space.2}',
        border: {
          radius: '{elements.radii.base}',
        },
        icon: {
          width: '{space.4}',
          height: '{space.4}'
        },
        boxShadow: {
          focus: '0 0 0 1px'
        }
      }
    },
  }
})