Skip to content

Commit

Permalink
Merge pull request #121 from DaniAcu/feat/add-container-aria-label
Browse files Browse the repository at this point in the history
feat: add container aria label
  • Loading branch information
wobsoriano authored Sep 12, 2024
2 parents 58fbef2 + e663da7 commit 920bd97
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 1 deletion.
5 changes: 5 additions & 0 deletions .changeset/shaggy-hounds-learn.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"svelte-sonner": patch
---

Add container aria label prop
3 changes: 2 additions & 1 deletion src/lib/Toaster.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@
export let theme: Exclude<$$Props['theme'], undefined> = 'light';
export let position = 'bottom-right';
export let hotkey: string[] = ['altKey', 'KeyT'];
export let containerAriaLabel: string = 'Notifications';
export let richColors = false;
export let expand = false;
export let duration: Exclude<$$Props['duration'], undefined> = 4000;
Expand Down Expand Up @@ -214,7 +215,7 @@
</script>

{#if $toasts.length > 0}
<section aria-label={`Notifications ${hotkeyLabel}`} tabIndex={-1}>
<section aria-label={`${containerAriaLabel} ${hotkeyLabel}`} tabIndex={-1}>
{#each possiblePositions as position, index}
<ol
tabIndex={-1}
Expand Down
7 changes: 7 additions & 0 deletions src/lib/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -184,6 +184,13 @@ export type ToasterProps = Partial<{
* @default '14px'
*/
gap: number;

/**
* Aria label to announce the notifications
* @default 'Notifications'
*
*/
containerAriaLabel?: string
}> &
HTMLOlAttributes;

Expand Down

0 comments on commit 920bd97

Please sign in to comment.