UI Logo

UI

Notification

A notification component for displaying alerts and messages.

'use client'

import { useState } from 'react'
import Notification from '@/components/ui/notification'

export default function NotificationDemo() {
  const [showNotification, setShowNotification] = useState(false)

  return (
    <div className='flex flex-col items-center justify-center gap-5 lg:flex-row'>
      <button onClick={() => setShowNotification(true)}>Show Notification</button>
      {showNotification && (
        <Notification
          type="success"
          message="Resource shared successfully!"
          duration={5000}
          onClose={() => setShowNotification(false)}
        />
      )}
    </div>
  )
}

Installation

Copy and paste the following code into your project.

Update the import paths to match your project setup.

Anatomy

Import all parts and piece them together.

import Notification from "@/components/ui/notification"
<Notification type="success" message="Sample message" />

Props

Type

Type

  • info
  • success
  • warning
  • error

Duration

Duration

  • number

Message

Message

  • string