Implement a reusable Notification Toast component.

Code Playground
JavaScript (V8)
Loading...
Console Output
// Output will appear here...
// For React: ReactDOM.createRoot(rootElement).render(<App />);
Recommended Answer
<template>
  <div class="toast" v-if="visible">{{ message }}</div>
</template>

<script setup>
import { ref } from 'vue';
const visible = ref(false);
const message = ref('');

const show = (msg) => {
  message.value = msg;
  visible.value = true;
  setTimeout(() => visible.value = false, 3000);
}
defineExpose({ show });
</script>

<style scoped>
.toast { position: fixed; bottom: 20px; right: 20px; background: #333; color: white; padding: 10px; }
</style>