custom-headless-alert-banner
v0.0.2
Published
A customizable alert banner component with Tailwind CSS
Readme
Custom Headless Alert Banner
A customizable alert banner component built with React and Tailwind CSS.
Installation
npm install custom-headless-alert-bannerUsage
import { AlertBanner } from "custom-headless-alert-banner";
function App() {
const handleClose = () => {
console.log("Alert closed");
};
return (
<div>
{/* Success Alert */}
<AlertBanner
type="success"
message="Your changes have been saved successfully!"
dismissible={true}
onClose={handleClose}
/>
{/* Error Alert */}
<AlertBanner
type="error"
message="An error occurred while saving your changes."
dismissible={true}
onClose={handleClose}
/>
{/* Info Alert */}
<AlertBanner
type="info"
message="Please review your information before submitting."
/>
{/* Warning Alert */}
<AlertBanner
type="warning"
message="Your session will expire in 5 minutes."
dismissible={true}
onClose={handleClose}
/>
</div>
);
}Props
| Prop | Type | Required | Default | Description |
| ------------- | --------------------------------------------- | -------- | ------- | ---------------------------------------------------- |
| type | 'success' \| 'error' \| 'info' \| 'warning' | Yes | - | The type of alert to display |
| message | string | Yes | - | The message to display in the alert |
| dismissible | boolean | No | false | Whether the alert can be dismissed |
| onClose | () => void | No | - | Callback function called when the alert is dismissed |
Alert Types
- Success: Green background with checkmark icon
- Error: Red background with exclamation circle icon
- Info: Blue background with information circle icon
- Warning: Yellow background with exclamation triangle icon
Styling
The component uses Tailwind CSS classes and is fully responsive. It automatically adjusts its layout and sizing based on screen size.
Dependencies
- React 18+
- @heroicons/react
- Tailwind CSS
License
ISC
