Skip to content

Commit

Permalink
docs: improve notification page
Browse files Browse the repository at this point in the history
  • Loading branch information
benjamincanac committed Jun 21, 2023
1 parent 2ea3587 commit 0272307
Showing 1 changed file with 54 additions and 14 deletions.
68 changes: 54 additions & 14 deletions docs/content/6.overlays/6.notification.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,19 @@ First of all, add the `Notifications` component to your app, preferably inside `
</template>
```

This component will render the notifications at the bottom right of the screen by default. You can configure its behavior in the `app.config.ts` through `ui.notifications`:

```ts [app.config.ts]
export default defineAppConfig({
ui: {
notifications: {
// Show toasts at the top right of the screen
position: 'top-0 right-0'
}
}
})
```

Then, you can use the `useToast` composable to add notifications to your app:

::component-example
Expand All @@ -36,19 +49,46 @@ const toast = useToast()
```
::

This component will render by default the notifications at the bottom right of the screen. You can configure its behavior in the `app.config.ts` through `ui.notifications`:
When using `toast.add`, this will push a new notification to the stack displayed in `<UNotifications />`. All the props of the `Notification` component can be passed to `toast.add`.

```ts [app.config.ts]
export default defineAppConfig({
ui: {
notifications: {
// Show toasts at the top right of the screen
position: 'top-0 right-0'
}
}
```vue
<script setup>
const toast = useToast()
onMounted(() => {
toast.add({
id: 'update_downloaded',
title: 'Update downloaded.',
description: 'It will be installed on restart. Restart now?',
icon: 'i-octicon-desktop-download-24',
timeout: 0,
actions: [{
label: 'Restart',
click: () => {
}
}]
})
})
</script>
```

You can also use the `Notification` component directly in your app as an alert for example.

### Title

Pass a `title` to your Notification.

::component-card
---
baseProps:
id: 1
timeout: 0
props:
title: 'Notification'
---
::

### Description

You can add a `description` in addition of the `title`.
Expand All @@ -58,8 +98,8 @@ You can add a `description` in addition of the `title`.
baseProps:
id: 2
timeout: 0
props:
title: 'Notification'
props:
description: 'This is a notification.'
---
::
Expand Down Expand Up @@ -125,7 +165,7 @@ Use the `color` prop to change the progress and icon color of the Notification.
::component-card
---
baseProps:
id: 5
id: 6
title: 'Notification'
description: 'This is a notification.'
timeout: 600000
Expand Down Expand Up @@ -194,7 +234,7 @@ You can pass all the props of the [Button](/elements/button) component to custom
::component-card
---
baseProps:
id: 6
id: 7
title: 'Notification'
timeout: 0
props:
Expand Down Expand Up @@ -235,7 +275,7 @@ Like for `closeButton`, you can pass all the props of the [Button](/elements/but
::component-card
---
baseProps:
id: 6
id: 8
title: 'Notification'
timeout: 0
props:
Expand All @@ -256,7 +296,7 @@ Actions will render differently whether you have a `description` set.
::component-card
---
baseProps:
id: 6
id: 9
title: 'Notification'
description: 'This is a notification.'
timeout: 0
Expand Down

0 comments on commit 0272307

Please sign in to comment.