Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@radix-ui/react-toast

Package Overview
Dependencies
Maintainers
6
Versions
152
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@radix-ui/react-toast

  • 1.2.2
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
850K
decreased by-15.04%
Maintainers
6
Weekly downloads
 
Created

What is @radix-ui/react-toast?

@radix-ui/react-toast is a React component library for creating customizable and accessible toast notifications. It provides a set of components and hooks to easily integrate toast notifications into your React application.

What are @radix-ui/react-toast's main functionalities?

Basic Toast

This code demonstrates how to create a basic toast notification using @radix-ui/react-toast. The ToastProvider component wraps the application, and the Toast component is used to display the notification with a title and description.

import { ToastProvider, Toast, ToastViewport } from '@radix-ui/react-toast';

function App() {
  return (
    <ToastProvider>
      <Toast>
        <Toast.Title>Notification</Toast.Title>
        <Toast.Description>This is a basic toast notification.</Toast.Description>
      </Toast>
      <ToastViewport />
    </ToastProvider>
  );
}

Auto Dismiss

This code demonstrates how to create a toast notification that automatically dismisses after a specified duration. The 'duration' prop is set to 5000 milliseconds (5 seconds) to achieve this behavior.

import { ToastProvider, Toast, ToastViewport } from '@radix-ui/react-toast';

function App() {
  return (
    <ToastProvider>
      <Toast duration={5000}>
        <Toast.Title>Auto Dismiss</Toast.Title>
        <Toast.Description>This toast will auto-dismiss after 5 seconds.</Toast.Description>
      </Toast>
      <ToastViewport />
    </ToastProvider>
  );
}

Custom Styling

This code demonstrates how to apply custom styles to a toast notification. The 'className' prop is used to add a custom CSS class to the Toast component, allowing for custom styling through an external CSS file.

import { ToastProvider, Toast, ToastViewport } from '@radix-ui/react-toast';
import './customStyles.css';

function App() {
  return (
    <ToastProvider>
      <Toast className='custom-toast'>
        <Toast.Title>Custom Styled Toast</Toast.Title>
        <Toast.Description>This toast has custom styles applied.</Toast.Description>
      </Toast>
      <ToastViewport />
    </ToastProvider>
  );
}

Other packages similar to @radix-ui/react-toast

FAQs

Package last updated on 01 Oct 2024

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc