Skip to content
On this page

Notifications

Notifications is used to display messages in an overlay.

Getting Started

Ideal location of a Toast is the main application template or application layout, so that it can be used by any component within the application.

Import HcNotificationsHub

js
import { HcNotificationsHub } from '@deeepvision/hope-component-kit';

and add it to your App or to layout.

html
<HcNotificationsHub />

Use notify function to add notification to HcNotificationsHub.

js
notify({
  text: 'Profile was successfully changed',
  icon: 'snack-info',
  type: 'success',
  duration: 100000,
})

NotificationParams:

OptionType
colorNamestring
colorstring
borderstring
iconstring
titlestring
textstring
loadingboolean
flatboolean
stickyboolean
squareboolean
notPaddingboolean
durationnumber
customClassstring
typeNotificationType
positionNotificationPosition
ts
type NotificationType = 'info' | 'warning' | 'success' | 'error';
ts
type NotificationPosition = 'bottom-right' | 'top-right' | 'top-center' | 'top-left' | 'bottom-left'| 'bottom-center';

Basic Usage

<template>
  <div class="flex justify-between items-end">
    <HcButton
      type="danger"
      @click="notify({
        text: 'Something went wrong.',
        icon: 'snack-error',
        type: 'error',
        duration: 100000,
      })"
    >
      danger
    </HcButton>

    <HcButton
      @click="notify({
        text: 'Profile was successfully changed',
        icon: 'snack-info',
        type: 'success',
        duration: 100000,
      })"
    >
      success
    </HcButton>

    <HcButton
      @click="notify({
        text: 'Account with this email is already created',
        icon: 'snack-info',
        type: 'warning',
        duration: 100000,
      })"
    >
      warning
    </HcButton>

    <HcButton
      @click="notify({
        text: 'Changes have been made in the field ...',
        icon: 'snack-info',
        type: 'info',
        duration: 100000,
      })"
    >
      info
    </HcButton>
  </div>
</template>
<script lang="ts" setup>
import { HcNotificationsHub, notify } from '@deeepvision/hope-component-kit';
</script>

Props

PropertyType Values Description Default
positionStringbottom-righttop-righttop-centertop-leftbottom-leftbottom-centernotification positionbottom-center
durationNumberNumberduration (in milliseconds) before close4000
widthStringStringcomponents width
appendStringtopbottomposition where append new notification in arraytop
animationStringfallingzoomingnotification animationfalling

Created by DeepVision Software.