Code
<PyxisButton
label="Notify me"
data-testid="notify-button"
@click="triggerNotification"
/>
<!-- We advise you to declare the notification component once
at the root of your project, for example 'App.vue'. -->
<PyxisNotification />
import { notify } from "@pyxis/pyxis"
const triggerNotification = () => {
notify({
type: "success",
title: `Title`,
description: `Success`,
})
}
// notify.ts
/**
* Emits a notification to the notification bus.
* @param notification { type: NotificationType, title: string, description?: string, size?: "default" | "compact", timeout?: number }
*/
Types
export type NotificationType = "success" | "warning" | "danger" | "info"
export type Notification = {
id: number
type: NotificationType
title: string
description?: string
size?: "default" | "compact";
dataTestid: string
progress: number
duration: ReturnType<typeof setInterval> | null
isHovered: boolean
show: boolean
timeout: number
}