Skip to content

Commit a4edcab

Browse files
committed
docs: update docs
1 parent e91a7c7 commit a4edcab

File tree

2 files changed

+27
-23
lines changed

2 files changed

+27
-23
lines changed

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,3 +24,5 @@ temp
2424
*.njsproj
2525
*.sln
2626
*.sw?
27+
28+
components.d.ts

README.md

Lines changed: 25 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -55,9 +55,9 @@ https://user-images.githubusercontent.com/6118824/228208185-be5aefd4-7fa8-4f95-a
5555
- [Close button](#close-button)
5656
- [Rich colors](#rich-colors)
5757
- [Custom offset](#custom-offset)
58-
- [Programmatically remove toast](#programmatically-remove-toast)
59-
- [Programmatically remove toast](#programmatically-remove-toast-1)
6058
- [On Close Callback](#on-close-callback)
59+
- [Persisting toasts](#persisting-toasts)
60+
- [Dismissing toasts programmatically](#dismissing-toasts-programmatically)
6161
- [Keyboard focus](#keyboard-focus)
6262
- [Inspiration](#inspiration)
6363
- [License](#license)
@@ -345,14 +345,14 @@ toast('Hello World', {
345345
Styling per toast type is also possible.
346346

347347
```vue
348-
<Toaster
348+
<Toaster
349349
:toastOptions="{
350350
unstyled: true,
351351
classes: {
352352
error: 'bg-red-400',
353353
success: 'text-green-400',
354354
warning: 'text-yellow-400',
355-
info: 'bg-blue-400',
355+
info: 'bg-blue-400'
356356
}
357357
}"
358358
/>
@@ -406,23 +406,19 @@ Offset from the edges of the screen.
406406
<Toaster offset="80px" />
407407
```
408408

409-
### Programmatically remove toast
410-
411-
To remove a toast programmatically use `toast.dismiss(id)`.
412-
413-
```ts
414-
const toastId = toast('Event has been created')
415-
416-
toast.dismiss(toastId)
417-
```
409+
### On Close Callback
418410

419-
You can also use the dismiss method without the id to dismiss all toasts.
411+
You can pass `onDismiss` and `onAutoClose` callbacks. `onDismiss` gets fired when either the close button gets clicked or the toast is swiped. `onAutoClose` fires when the toast disappears automatically after it's timeout (`duration` prop).
420412

421413
```ts
422-
toast.dismiss()
414+
toast('Event has been created', {
415+
onDismiss: (t) => console.log(`Toast with id ${t.id} has been dismissed`),
416+
onAutoClose: (t) =>
417+
console.log(`Toast with id ${t.id} has been closed automatically`)
418+
})
423419
```
424420

425-
### Programmatically remove toast
421+
### Persisting toasts
426422

427423
You can change the duration of each toast by using the duration property, or change the duration of all toasts like this:
428424

@@ -435,22 +431,28 @@ toast('Event has been created', {
435431
duration: 10000
436432
})
437433

434+
If you want a toast to stay on screen forever, you can set the duration to `Infinity`.
435+
438436
// Persisent toast
439437
toast('Event has been created', {
440438
duration: Infinity
441439
})
442440
```
443441

444-
### On Close Callback
442+
### Dismissing toasts programmatically
445443

446-
You can pass `onDismiss` and `onAutoClose` callbacks. `onDismiss` gets fired when either the close button gets clicked or the toast is swiped. `onAutoClose` fires when the toast disappears automatically after it's timeout (`duration` prop).
444+
To remove a toast programmatically use `toast.dismiss(id)`.
447445

448446
```ts
449-
toast('Event has been created', {
450-
onDismiss: (t) => console.log(`Toast with id ${t.id} has been dismissed`),
451-
onAutoClose: (t) =>
452-
console.log(`Toast with id ${t.id} has been closed automatically`)
453-
})
447+
const toastId = toast('Event has been created')
448+
449+
toast.dismiss(toastId)
450+
```
451+
452+
You can also dismiss all toasts at once by calling `toast.dismiss()` without an id.
453+
454+
```ts
455+
toast.dismiss()
454456
```
455457

456458
### Keyboard focus

0 commit comments

Comments
 (0)