Notification

Display notifications and alerts to users. This is the base component for building notification systems.

Import

import { Notification } from '@tidbcloud/uikit'

Basic Usage

import { Notification } from '@tidbcloud/uikit'
 
function Demo() {
  return <Notification title="Default notification">This is a notification message</Notification>
}

With Icon

import { Notification } from '@tidbcloud/uikit'
import { IconCheck, IconX } from '@tabler/icons-react'
 
function Demo() {
  return (
    <>
      <Notification icon={<IconCheck size={20} />} color="teal" title="Success!">
        Your changes have been saved
      </Notification>
 
      <Notification icon={<IconX size={20} />} color="red" title="Error!">
        Something went wrong
      </Notification>
    </>
  )
}

With Close Button

import { Notification } from '@tidbcloud/uikit'
 
function Demo() {
  return (
    <Notification title="Dismissable notification" withCloseButton onClose={() => console.log('closed')}>
      Click the close button to dismiss
    </Notification>
  )
}

Loading State

import { Notification } from '@tidbcloud/uikit'
 
function Demo() {
  return (
    <Notification loading title="Uploading...">
      Please wait while we upload your file
    </Notification>
  )
}

Key Props

PropTypeDescription
titleReactNodeNotification title
childrenReactNodeNotification message body
iconReactNodeIcon displayed on the left
colorMantineColorColor for icon or line
loadingbooleanShows loader instead of icon
withCloseButtonbooleanShows close button
onClose() => voidCalled when close button clicked
withBorderbooleanAdds border to notification
radiusMantineRadiusBorder radius
closeButtonPropsobjectProps for close button