Skip to content

Commit 2a86756

Browse files
authored
Update Toast usage instructions (#4288)
1 parent 066e354 commit 2a86756

File tree

1 file changed

+38
-4
lines changed
  • sites/skeleton.dev/src/content/docs/framework-components

1 file changed

+38
-4
lines changed

sites/skeleton.dev/src/content/docs/framework-components/toast.mdx

Lines changed: 38 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -49,10 +49,9 @@ import TypeSvelteRaw from '@/components/examples/framework-components/toast/svel
4949

5050
## Usage
5151

52-
This component acts as a Singleton. Implement a single instance of `<Toast.Group>` in the root scope your application, then trigger it anywhere on demand using a shared `createToaster()` instance.
52+
This component acts as a Singleton. Implement a single instance of `<Toast.Group>` in the root scope your application.
5353

5454
<Framework id="react">
55-
5655
```tsx
5756
import { toaster } from '/some/path/toaster.ts';
5857
import { Toast } from '@skeletonlabs/skeleton-react';
@@ -80,7 +79,6 @@ This component acts as a Singleton. Implement a single instance of `<Toast.Group
8079

8180
</Framework>
8281
<Framework id="svelte">
83-
8482
```svelte
8583
<script lang="ts">
8684
import { toaster } from '/some/path/toaster.ts';
@@ -111,8 +109,32 @@ This component acts as a Singleton. Implement a single instance of `<Toast.Group
111109

112110
</Framework>
113111

112+
Create a shared reference to the `createToaster()` instance. We'll call it `toaster` here.
113+
114114
<Framework id="react">
115+
```ts
116+
<script lang="ts">
117+
import { createToaster } from '@skeletonlabs/skeleton-react';
118+
119+
export const toaster = createToaster();
120+
</script>
121+
```
122+
123+
</Framework>
124+
<Framework id="svelte">
125+
```ts
126+
<script lang="ts">
127+
import { createToaster } from '@skeletonlabs/skeleton-svelte';
128+
129+
export const toaster = createToaster();
130+
</script>
131+
```
132+
133+
</Framework>
115134

135+
Use this shared reference to trigger messages on demand throughout your application.
136+
137+
<Framework id="react">
116138
```tsx
117139
import { toaster } from '/some/path/toaster.ts';
118140

@@ -126,7 +148,6 @@ This component acts as a Singleton. Implement a single instance of `<Toast.Group
126148

127149
</Framework>
128150
<Framework id="svelte">
129-
130151
```svelte
131152
<script lang="ts">
132153
import { toaster } from '/some/path/toaster.ts';
@@ -138,6 +159,19 @@ This component acts as a Singleton. Implement a single instance of `<Toast.Group
138159
</script>
139160
```
140161

162+
</Framework>
163+
<Framework id="react">
164+
```tsx
165+
import { toaster } from '/some/path/toaster.ts';
166+
167+
export default function Page() {
168+
function onClickHandler() {
169+
toaster.info({ title: 'Example', description: 'This is a toast message.' });
170+
}
171+
return ();
172+
}
173+
```
174+
141175
</Framework>
142176

143177
## Triggers

0 commit comments

Comments
 (0)