<Alert> Component

<Alert> is a UI for displaying feedback messages.

Here the demo:

Preview

Installing <Alert> Component

There are 2 ways to install <Alert> component into your react app project:

  • Install the Specific Package of <Alert> Component
  • Install the Whole Reusable-UI Component Pack, including the <Alert> Component

expanded Property

Expands/Collapses the <Alert>.

The possible values are:

  • undefined
  • true
  • false

Here the preview:

Preview

<Alert expanded={true}> 

Show code

onExpandedChange Property

Sets a callback function to be called when the user closes the <Alert>.

The callback function parameters:

  • event: ExpandedChangeEvent

icon Property

Select an icon set (a string value) corresponding to the icon image.

There are 2 types of icon sets: Built-in icon set and Custom icon set.

Built-in Icon Sets

There a pretty much of common icon sets that ready to use for general projects.

Show icon gallery

Adding Custom Icon Sets

To add custom icons, for example a logo icon, follow these steps:

  • Prepare the Image
  • Store the Image
  • Registering the Custom Icons
  • Using the Registered Custom Icons

lazy Property

Determines whenever the <Alert>'s children should be rendered or not when the <Alert expanded={false}>.

The possible values are:

  • undefined
  • false
  • true

Floating Properties

Determines how the <Alert> should be floating on the target DOM reference.

floatingOn Property

Determines the target DOM reference where the <Alert> should be floating on.
If not set (undefined), the <Alert> becomes a normal element flow.


Here the preview:

Preview

Show code

floatingPlacement Property

Determines the location where the <Alert> should be floating on the target DOM reference.


Here the preview:

floatingPlacement='top'

floatingStrategy Property

Determines the technical strategy how the <Alert> can float.
In most cases, you should not worry about the detail mechanism how the <Alert> can float.

The possible values are:

  • undefined
  • 'absolute'
  • 'fixed'

floatingAutoFlip Property

Automatically flips the floatingPlacement to opposite direction when the <Alert> is about to be clipped.

The possible values are:

  • undefined
  • true
  • false

Here the preview:

Preview

Show code

floatingAutoShift Property

Automatically shifts the floatingPlacement to nearest safe position when the <Alert> is about to be clipped.

The possible values are:

  • undefined
  • true
  • false

Here the preview:

Preview

Show code

floatingOffset Property

The distance (in pixel) between the <Alert> and the target DOM reference.

The possible values are:

  • undefined
  • 0
  • positive number
  • negative number

Here the preview:

Preview

<Alert floatingOffset={0}>

Show code

floatingShift Property

The distance (in pixel) between the <Alert> and the default floatingPlacement location.

The possible values are:

  • undefined
  • 0
  • positive number
  • negative number

Here the preview:

Preview

<Alert floatingShift={0}>

Show code

onFloatingUpdate Property

Sets a callback function to be called when the <Alert> updates the position relative to the target DOM reference.

The callback function parameters:

  • event: FloatingPosition

Variant Properties

The alternative appearances of the <Alert> layout without changing the <Alert>'s functionality.

size Property

Defines the alternative size of the <Alert>.

The possible values are:

  • undefined
  • 'sm'
  • 'md'
  • 'lg'

Here the preview:

Preview

Show code

theme Property

Defines the contextual theme of the <Alert>.

The possible values are:

  • undefined
  • 'primary'
  • 'secondary'
  • 'success'
  • 'info'
  • 'warning'
  • 'danger'
  • 'light'
  • 'dark'

Here the preview:

Preview

Show code

gradient Property

Activates a 3D mode of the <Alert>.

The possible values are:

  • undefined
  • 'inherit'
  • true
  • false

Here the preview:

Preview

Show code

outlined Property

Activates an outlined mode (background-less, contrast foreground, and contrast border) of the <Alert>.

The possible values are:

  • undefined
  • 'inherit'
  • true
  • false

Here the preview:

Preview

Show code

mild Property

Activates a mild mode (mild background, contrast foreground, and contrast border) of the <Alert>.

The possible values are:

  • undefined
  • 'inherit'
  • true
  • false

Here the preview:

Preview

Show code

nude Property

Activates an nude mode (background-less, padding-less, and border-less) of the <Alert>.

The possible values are:

  • undefined
  • true
  • false

Here the preview:

Preview

Show code

Component Properties

Overwrites the internal (sub) components used as the composition of <Alert> component.

iconComponent Property

Overwrites the internal <Icon> component used as the composition of <Alert> component.

<Alert iconComponent={
    <MyCustomIcon />
} />

controlComponent Property

Overwrites the internal <CloseButton> component used as the composition of <Alert> component.

<Alert controlComponent={
    <MyCustomCloseButton />
} />

Variables

There are several variables of <Alert> you can customize. Changing the variables affects all <Alert> instance and other components that depend on <Alert>.

Here the exposed variables:

  • Spacings

The example of accessing, modifying, & adding variables:

Show code