Toast Provider
For managing toast notifications globally in your application, use the <CLToastProvider /> component in combination with the useToast composable. This provides a convenient way to show toast notifications from anywhere in your application without managing the toast state manually.
Usage
vue
<!-- Root component -->
<script setup lang="ts">
import CLThemeProvider from '@codeandfunction/callaloo/CLThemeProvider';
import CLToastProvider from '@codeandfunction/callaloo/CLToastProvider';
</script>
<template>
<div class="my-app">
<CLThemeProvider>
<CLToastProvider>
<ChildComponent />
</CLToastProvider>
</CLThemeProvider>
</div>
</template>
<!-- Child component -->
<script setup lang="ts">
import CLButton from '@codeandfunction/callaloo/CLButton';
import { CLColors, CLIconNames, useToast } from '@codeandfunction/callaloo';
const { showToast } = useToast();
const showSuccessToast = () => {
showToast({
color: CLColors.Success,
icon: CLIconNames.CheckCircle,
title: 'Success',
message: 'Operation completed successfully!'
});
};
</script>
<template>
<CLButton @click="showSuccessToast">Show Success Toast</CLButton>
</template>