{"id":13615036,"url":"https://github.com/keenethics/svelte-notifications","last_synced_at":"2025-10-05T08:37:36.223Z","repository":{"id":34979597,"uuid":"187907456","full_name":"keenethics/svelte-notifications","owner":"keenethics","description":"Simple and flexible notifications system","archived":false,"fork":false,"pushed_at":"2024-02-06T15:57:03.000Z","size":1298,"stargazers_count":581,"open_issues_count":10,"forks_count":30,"subscribers_count":6,"default_branch":"master","last_synced_at":"2025-05-11T04:24:20.846Z","etag":null,"topics":["notifications","svelte","svelte-components","toast"],"latest_commit_sha":null,"homepage":"https://svelte-notifications.netlify.com","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/keenethics.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":"CONTRIBUTING.md","funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2019-05-21T20:18:44.000Z","updated_at":"2025-03-17T21:04:18.000Z","dependencies_parsed_at":"2024-06-18T14:16:23.689Z","dependency_job_id":null,"html_url":"https://github.com/keenethics/svelte-notifications","commit_stats":{"total_commits":106,"total_committers":21,"mean_commits":"5.0476190476190474","dds":0.3207547169811321,"last_synced_commit":"0c1c2f70603d02a0e98935c88217bd9297c1e4ea"},"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/keenethics%2Fsvelte-notifications","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/keenethics%2Fsvelte-notifications/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/keenethics%2Fsvelte-notifications/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/keenethics%2Fsvelte-notifications/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/keenethics","download_url":"https://codeload.github.com/keenethics/svelte-notifications/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":254422761,"owners_count":22068678,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["notifications","svelte","svelte-components","toast"],"created_at":"2024-08-01T20:01:08.511Z","updated_at":"2025-10-05T08:37:31.204Z","avatar_url":"https://github.com/keenethics.png","language":"JavaScript","funding_links":[],"categories":["JavaScript","components and libraries"],"sub_categories":["notifications"],"readme":"![build](https://img.shields.io/circleci/build/github/keenethics/svelte-notifications/master.svg)\n![version](https://img.shields.io/github/package-json/v/keenethics/svelte-notifications.svg)\n![license](https://img.shields.io/github/license/mashape/apistatus.svg)\n\n# Svelte notifications\n\nSimple and flexible notifications system for Svelte 3\n\n![Svelte Notifications](https://github.com/keenethics/svelte-notifications/blob/media/svelte-notifications-preview.png?raw=true)\n\n## Demonstration\n\n[https://svelte-notifications.netlify.com](https://svelte-notifications.netlify.com)\n\n## Getting started\n\n```bash\nnpm install --save svelte-notifications\n```\n\n## Basic usage\n\n```svelte\n// MainComponent.svelte\n\n\u003cscript\u003e\n  import Notifications from 'svelte-notifications';\n\n  import App from './App.svelte';\n\u003c/script\u003e\n\n\u003cNotifications\u003e\n  \u003cApp /\u003e\n\u003c/Notifications\u003e\n```\n\n```svelte\n// ChildrenComponent.svelte\n\n\u003cscript\u003e\n  import { getNotificationsContext } from 'svelte-notifications';\n\n  const { addNotification } = getNotificationsContext();\n\u003c/script\u003e\n\n\u003cbutton\n  on:click={() =\u003e addNotification({\n    text: 'Notification',\n    position: 'bottom-center',\n  })}\n\u003e\n  Add notification\n\u003c/button\u003e\n```\n\n## Providing custom notification component\n\n```svelte\n// MainComponent.svelte\n\n\u003cscript\u003e\n  import Notifications from 'svelte-notifications';\n  import CustomNotification from './CustomNotification.svelte';\n\n  import App from './App.svelte';\n\u003c/script\u003e\n\n\u003cNotifications item={CustomNotification}\u003e\n  \u003cApp /\u003e\n\u003c/Notifications\u003e\n```\n\n```svelte\n// CustomNotification.svelte\n\n\u003cscript\u003e\n  export let notification = {};\n  // `onRemove` function will be passed into your component.\n  export let onRemove = null;\n\n  const handleButtonClick = () =\u003e {\n    onRemove();\n  }\n\u003c/script\u003e\n\n\u003cdiv class={notification.type === 'error' ? 'error' : ''}\u003e\n  \u003ch4\u003e{notification.heading}\u003c/h4\u003e\n  \u003cp\u003e{notification.description}\u003c/p\u003e\n  \u003cbutton on:click={handleButtonClick}\u003eClose me\u003c/button\u003e\n\u003c/div\u003e\n```\n\n```svelte\n// AnotherComponent.svelte\n\n\u003cscript\u003e\n  import { getNotificationsContext } from 'svelte-notifications';\n\n  const { addNotification } = getNotificationsContext();\n\n  const handleButtonClick = () =\u003e {\n    addNotification({\n      position: 'bottom-right',\n      heading: 'hi i am custom notification',\n      type: 'error',\n      description: 'lorem ipsum',\n    });\n  }\n\u003c/script\u003e\n\n\u003cdiv\u003e\n  \u003cbutton on:click={handleButtonClick}\u003eShow notification\u003c/button\u003e\n\u003c/div\u003e\n```\n\n## API\n\n#### `Notifications`\n\nThe `Notifications` component supplies descendant components with notifications store through context.\n\n- @prop {component} `[item=null]` - Custom notification component that receives the notification object\n- @prop {boolean} `[withoutStyles=false]` - If you don't want to use the default styles, this flag will remove the classes to which the styles are attached\n- @prop {string|number} `[zIndex]` - Adds a style with z-index for the notification container\n\n```svelte\n// MainComponent.svelte\n\n\u003cscript\u003e\n  import Notifications from 'svelte-notifications';\n\n  import App from './App.svelte';\n\u003c/script\u003e\n\n\u003cNotifications\u003e\n  \u003cApp /\u003e\n\u003c/Notifications\u003e\n```\n\n#### `getNotificationsContext`\n\nA function that allows you to access the store and the functions that control the store.\n\n```svelte\n// ChildrenComponent.svelte\n\n\u003cscript\u003e\n  import { getNotificationsContext } from 'svelte-notifications';\n\n  const notificationsContext = getNotificationsContext();\n\n  const {\n    addNotification,\n    removeNotification,\n    clearNotifications,\n    subscribe,\n  } = notificationsContext;\n\u003c/script\u003e\n```\n\n#### `getNotificationsContext:addNotification`\n\nYou can provide any object that the notification component will receive. The default object looks like this:\n\n- @param {Object} `notification` - The object that will receive the notification component\n- @param {string} `[id=timestamp-rand]` - Unique notification identificator\n- @param {string} `text` – Notification text\n- @param {string} `[position=bottom-center]` – One of these values: `top-left`, `top-center`, `top-right`, `bottom-left`, `bottom-center`, `bottom-right`\n- @param {string} `type` – One of these values: `success`, `warning`, `error`\n- @param {number} `[removeAfter]` – After how much the notification will disappear (in milliseconds)\n\n```svelte\n// ChildrenComponent.svelte\n\n\u003cscript\u003e\n  import { getNotificationsContext } from 'svelte-notifications';\n\n  const { addNotification } = getNotificationsContext();\n\n  addNotification({\n    id: 'uniqNotificationId',\n    text: 'Notification',\n    position: 'top-center',\n    type: 'success',\n    removeAfter: 4000,\n    ...rest,\n  });\n\u003c/script\u003e\n```\n\n#### `getNotificationsContext:removeNotification`\n\n- @param {string} `id` - Unique notification identificator\n\n```svelte\n// ChildrenComponent.svelte\n\n\u003cscript\u003e\n  import { getNotificationsContext } from 'svelte-notifications';\n\n  const { removeNotification } = getNotificationsContext();\n\n  removeNotification('uniqNotificationId');\n\u003c/script\u003e\n```\n\n#### `getNotificationsContext:clearNotifications`\n\n```svelte\n// ChildrenComponent.svelte\n\n\u003cscript\u003e\n  import { getNotificationsContext } from 'svelte-notifications';\n\n  const { clearNotifications } = getNotificationsContext();\n\n  clearNotifications();\n\u003c/script\u003e\n```\n\n#### `getNotificationsContext:subscribe`\n\nDefault Svelte subscribe method that allows interested parties to be notified whenever the store value changes\n\n## Contributing\n\nRead more about contributing [here](/CONTRIBUTING.md)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fkeenethics%2Fsvelte-notifications","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fkeenethics%2Fsvelte-notifications","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fkeenethics%2Fsvelte-notifications/lists"}