0.1.1 • Published 10 months ago
ashish-baisla-library v0.1.1
Ashish Baisla Component Library
This is a collection of reusable components developed by Ashish Baisla. The library includes various components that can be easily integrated into your React or Next.js projects to enhance their functionality and user experience.
Installation
To install the Ashish Baisla Component Library, you can use npm or yarn:
npm install ashish-baisla-library
or
yarn add ashish-baisla-library
Components
Toast
The Toast component provides a simple notification popup to display messages to users. It can be used to show success messages, errors, warnings, or general information. You can customize the message, type, and automatic dismissal duration (optional).
import React, { useState } from 'react';
import { Toast } from 'ashish-baisla-library';
const App = () => {
const [showToast, setShowToast] = useState(false);
const handleShowToast = () => {
setShowToast(true);
};
const handleCloseToast = () => {
setShowToast(false);
};
return (
<div>
<button onClick={handleShowToast}>Show Toast</button>
<Toast
visibility={showToast}
message="Hello, I am working"
type="success"
autoDismissDuration={5000}
onClose={handleCloseToast}
/>
</div>
);
};
export default App;
API Reference
Toast Props
Prop | Type | Default | Description |
---|---|---|---|
visibility | boolean | false | Controls the visibility of the toast. |
message | string | The message to be displayed in the toast. | |
type | 'success' | 'error' | 'warning' | 'information' | string | 'success' | The type of toast, which determines the icon and style. |
autoDismissDuration | number | 'none' | 'none' | The duration (in milliseconds) before the toast automatically dismisses. Use 'none' for manual dismissal. Default is 'none'. |
onClose | () => void | Callback function to handle the close event when the toast is dismissed. |
License
This project is licensed under the MIT License.
Author
- Aashish Baisla
- GitHub: @AashishBaisla