An accessible toast library for React.
Documentation Β Β β¦Β Β Getting Started Β Β β¦Β Β Contribute Β Β β¦Β Β Roadmap Β Β β¦Β Β License
- π Lightweight.
- β Accessible.
- π¨ Light/dark mode.
- β²οΈ Don't close automatically when the user hover over the toast.
- ποΈ Customizable toast position.
- π Disable transitions if the user has disabled them in the system.
- π Built completely with Typescript.
- π¨ Notification Design by Medusa.js UI Framework.
- π οΈ Typescript API by Sonner.
- πͺ Phosphor Icons for success, error, warning, info & loading icons.
Important
This library requires React v18 or higher.
- Install the library:
# Using npm:
npm install @pheralb/toast
# Using pnpm:
pnpm add @pheralb/toast
# Using yarn:
yarn install @pheralb/toast
- Add the toast provider:
// π root.tsx
import { Toaster } from '@pheralb/toast';
ReactDOM.createRoot(document.getElementById('root')!).render(
<React.StrictMode>
<App />
<Toaster />
</React.StrictMode>,
);
- Usage:
// π index.tsx
import { toast } from '@pheralb/toast';
export default function Index() {
return (
<>
<button
onClick={() =>
toast.success({
text: 'pheralb/toast',
description: 'β¨ A beautiful toast library for React',
})
}
>
<span>Render a toast</span>
</button>
</>
);
}
Tip
π Visit the Documentation for more information.
- π Add
.loading
variant. - π Add support for Astro + React.
- π¨ Add rich colors support.
pheralb/toast
is a monorepo built with Turbo and it uses:
- Docs: Astro Content Collections, shadcn/ui + Tailwind CSS & MDX.
- Library: React 18 with tsup + Vitest for testing.
- Examples: Frameworks to test the library.
-
Click here to fork the repository.
-
Install dependencies:
# Install pnpm globally if you don't have it:
npm install -g pnpm
# and install dependencies:
pnpm install
- Commands:
# Run only documentation website:
pnpm dev:docs
# Run all packages with examples:
pnpm dev
# Build the docs & library:
pnpm build
# Test the library:
pnpm test
- π§βπ Open
http://localhost:4321
to view the Astro documentation website. - π Open
http://localhost:3000
to view the Next.js playground. Only for test the functionality of the library.
and create a pull request with your features or fixes πβ¨.
MIT License - pheralb 2024.