A lightweight, customizable, and reusable Alert Component built with React, TypeScript, and Vite. Perfect for displaying notifications, success messages, errors, and warnings in your React applications.
- π― Simple & Lightweight - Minimal dependencies, maximum performance
- π§ Fully Customizable - Easy to modify colors, styles, and behavior
- π± Responsive Design - Works seamlessly on all screen sizes
- π Type-Safe - Built with TypeScript for better developer experience
- π¨ Modern Icons - Powered by Lucide React for crisp, scalable icons
- β‘ Lightning Fast - Built with Vite for optimal development experience
- π Reusable Component - Drop-in solution for any React project
Check out the live demo: Simple React Alerts
// Example usage
<Alert
type="success"
message="Your data has been saved successfully!"
isVisible={showAlert}
onClose={() => setShowAlert(false)}
/>
Purpose | Technology |
---|---|
Frontend Library | React 18.3.1 |
Language | TypeScript |
Build Tool | Vite |
Styling | SCSS (Sass) |
Icons | Lucide React |
Code Quality | ESLint + Prettier |
Deployment | GitHub Pages |
git clone https://github.com/abdelrahman-samy-dev/simple-react-alerts.git
cd simple-react-alerts
npm install
npm run dev
npm run build
npm run preview
npm run deploy
simple-react-alerts/
βββ public/
β βββ vite.svg
βββ src/
β βββ components/
β β βββ Alert.tsx # Main Alert Component
β βββ styles/
β β βββ Alert.scss # Component Styles
β βββ App.tsx # Demo Application
β βββ main.tsx # Entry Point
β βββ vite-env.d.ts
βββ package.json
βββ tsconfig.json
βββ vite.config.ts
βββ README.md
import React, { useState } from 'react';
import Alert from './components/Alert';
function App() {
const [showAlert, setShowAlert] = useState(false);
return (
<div>
<button onClick={() => setShowAlert(true)}>
Show Alert
</button>
<Alert
type="success"
message="Operation completed successfully!"
isVisible={showAlert}
onClose={() => setShowAlert(false)}
/>
</div>
);
}
The component supports multiple alert types:
success
- Green alert for positive actionserror
- Red alert for errors and failureswarning
- Yellow alert for warningsinfo
- Blue alert for informational messages
interface AlertProps {
type: 'success' | 'error' | 'warning' | 'info';
message: string;
isVisible: boolean;
onClose: () => void;
autoClose?: boolean;
duration?: number;
}
The component uses SCSS for styling. You can easily customize colors, animations, and layout by modifying the Alert.scss
file:
// Custom color scheme
.alert {
&--success {
background-color: #your-color;
border-color: #your-border-color;
}
}
Icons are provided by Lucide React. You can easily swap icons by importing different ones from the library.
The alert component is fully responsive and adapts to different screen sizes:
- Desktop: Full-width with comfortable padding
- Tablet: Adjusted spacing and font sizes
- Mobile: Optimized for touch interactions
- Bundle Size: Minimal footprint with tree-shaking
- Rendering: Optimized with React hooks
- Animations: Smooth CSS transitions
- Loading: Fast initial load with Vite optimization
Command | Description |
---|---|
npm run dev |
Start development server |
npm run build |
Build for production |
npm run preview |
Preview production build |
npm run lint |
Run ESLint |
npm run deploy |
Deploy to GitHub Pages |
Contributions are welcome! Please feel free to submit a Pull Request. For major changes, please open an issue first to discuss what you would like to change.
- Fork the repository
- Create your feature branch (
git checkout -b feature/AmazingFeature
) - Commit your changes (
git commit -m 'Add some AmazingFeature'
) - Push to the branch (
git push origin feature/AmazingFeature
) - Open a Pull Request
This project is open source and available under the MIT License.
Abdelrahman Samy
- GitHub: @abdelrahman-samy-dev
- LinkedIn: Connect with me
- React - The web framework used
- TypeScript - For type safety
- Vite - For blazing fast development
- Lucide React - For beautiful icons
- GitHub Pages - For free hosting
β If you found this project helpful, please give it a star! β