npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

tona-sonner

v1.0.23

Published

Preact toast notification component based on sonner

Readme

tona-sonner

English | 中文

特性

  • 精美设计 - 简洁现代的 Toast 通知
  • 多种类型 - 成功、错误、警告、信息 Toast
  • 高度可定制 - 外观和行为高度可配置
  • 暗黑模式 - 内置暗黑主题支持
  • 动画效果 - 平滑的进入/退出动画
  • TypeScript - 包含完整的类型定义

安装

npm install tona-sonner
pnpm add tona-sonner
yarn add tona-sonner

使用

import { Toaster, toast } from 'tona-sonner'

function App() {
  return (
    <div>
      <button onClick={() => toast.success('Hello World!')}>Show Toast</button>
      <Toaster />
    </div>
  )
}

Toast 类型

// 不同的 Toast 类型
toast.success('Success!')
toast.error('Error!')
toast.warning('Warning!')
toast.info('Info!')
toast.default('Default message')

带选项的 Toast

// 带描述
toast.success('Success!', {
  description: 'Your action was completed successfully.',
})

// 带操作
toast.error('Error occurred', {
  description: 'Something went wrong',
  action: {
    label: 'Retry',
    onClick: () => console.log('Retrying...'),
  },
})

// 自定义持续时间
toast.info('This will close in 5 seconds', {
  duration: 5000,
})

Toaster 组件

<Toaster
  position="bottom-right" // Toast 位置
  gap={14} // Toast 之间的间距
  visibleToasts={3} // 最大可见 Toast 数量
/>

默认配置

  • 位置: bottom-right
  • 间距: 14px
  • 可见 Toast 数: 3
  • 持续时间: 3000ms
  • 关闭按钮: 始终可见
  • 默认堆叠,悬停时展开

关闭 Toast

const toastId = toast.success('Hello!')

// 关闭特定 Toast
toast.dismiss(toastId)

// 关闭所有 Toast
toast.dismiss()

自动挂载

Toaster 在导入时会自动挂载到 document body。您也可以手动挂载:

import { mountToaster } from 'tona-sonner'

// 挂载到 document body
mountToaster()

// 挂载到自定义容器
const container = document.getElementById('toast-container')
mountToaster(container)

样式

导入 CSS 文件:

import 'tona-sonner/dist/index.css'

或使用 CSS 变量自定义:

:root {
  --toast-background: #fff;
  --toast-border: 1px solid #e5e5e5;
  --toast-border-radius: 8px;
}

对等依赖

{
  "preact": ">=10.0.0"
}

相关