@@ -6,4 +6,121 @@ source: https://github.com/typlog/ui/tree/main/src/components/toggtoastle
66reka : https://reka-ui.com/docs/components/toast
77---
88
9+ <script setup >
10+ import { ref } from ' vue'
11+ import { ToastProvider , Button , toast } from ' #components'
12+
13+ const size = ref (' 1' )
14+ const position = ref (' bottom-right' )
15+
16+ const changePosition = (value ) => {
17+ position .value = value
18+ toast (` Position changed to: ${ value} ` )
19+ }
20+
21+ const changeSize = (value ) => {
22+ size .value = value
23+ toast (` Size changed to: ${ value} ` )
24+ }
25+ </script >
26+
27+ <ToastProvider :size =" size " :position =" position " />
28+
929<Example name =" toast/Overview.vue " variant =" full " />
30+
31+ ## Provider
32+
33+ To use the ` toast ` module, you need to set up the ` ToastProvider ` first. Simply
34+ place it within the ` ThemeProvider ` – its position doesn't matter, and it will
35+ function as expected.
36+
37+ ``` vue
38+ <script setup>
39+ import { ThemeProvider, ToastProvider } from '@typlog/ui'
40+ </script>
41+ <template>
42+ <ThemeProvider>
43+ <ToastProvider />
44+ </ThemeProvider>
45+ </template>
46+ ```
47+
48+ ### Position
49+
50+ You can customize the position of toast messages using the ` position ` prop on ` ToastProvider ` .
51+ By default, toasts appear in the bottom-right corner.
52+
53+ <ExampleCode name =" Position " variant =" full " >
54+
55+ <div class =" flex flex-wrap items-center gap-4 " >
56+ <Button @click ="changePosition('top-left')" variant="surface">Top left</Button >
57+ <Button @click ="changePosition('top-right')" variant="surface">Top right</Button >
58+ <Button @click ="changePosition('bottom-left')" variant="surface">Bottom left</Button >
59+ <Button @click ="changePosition('bottom-right')" variant="surface">Bottom right</Button >
60+ </div >
61+
62+ <template #source>
63+
64+ <div class =" language-vue " >
65+ <pre class =" shiki " ><code >< ; ToastProvider
66+ <span style =" color : var (--red-10 )" >position="{{ position }}"</span >
67+ /> ;
68+ </code ></pre >
69+ </div >
70+
71+ </template >
72+
73+ </ExampleCode >
74+
75+
76+ ### Size
77+
78+ You can customize the size of toast messages using one of the three available ` size ` options.
79+
80+ <ExampleCode name =" Size " variant =" full " >
81+
82+ <div class =" flex flex-wrap items-center gap-4 " >
83+ <Button @click ="changeSize('1')" variant="surface">Size 1</Button >
84+ <Button @click ="changeSize('2')" variant="surface">Size 2</Button >
85+ <Button @click ="changeSize('3')" variant="surface">Size 3</Button >
86+ </div >
87+
88+ <template #source>
89+
90+ <div class =" language-vue " >
91+ <pre class =" shiki " ><code >< ; ToastProvider
92+ <span style =" color : var (--red-10 )" >size="{{ size }}"</span >
93+ /> ;
94+ </code ></pre >
95+ </div >
96+
97+ </template >
98+
99+ </ExampleCode >
100+
101+ ## Examples
102+
103+ ### Methods
104+
105+ <div class =" flex flex-wrap items-center gap-4 not-prose " >
106+ <Button @click ="toast.info('A info message')">
107+ <code >toast.info</code >
108+ </Button >
109+ <Button @click ="toast.success('A success message')" color="green">
110+ <code >toast.success</code >
111+ </Button >
112+ <Button @click ="toast.warning('A warning message')" color="orange">
113+ <code >toast.warning</code >
114+ </Button >
115+ <Button @click ="toast.error('A error message')" color="red">
116+ <code >toast.error</code >
117+ </Button >
118+ </div >
119+
120+ ### Promise
121+
122+ <Example name =" toast/Promise.vue " />
123+
124+ ### Description
125+
126+ <Example name =" toast/Description.vue " variant =" full " />
0 commit comments