Overview
TheFeedback component displays toast-style notifications that slide in from the bottom-left corner, auto-dismiss after a specified duration, and provide visual feedback for user actions. It supports success, error, and custom types.
Import
Usage
Basic Success Message
Error Message
Custom Duration
With Manual Close Button
Custom Type with Icon
Complete Implementation Example
Props
Controls visibility and triggers show/hide animation.
- Set to
trueto show the feedback - Animation plays on state change
- Component automatically sets to
falseaftercloseAfterduration
Visual variant of the feedback notification.Options:
"success"- Green background with check icon"error"- Red background with X icon"custom"- Custom background with custom icon (requiresiconprop)
Message text to display in the notification.Keep concise for better UX (1-2 short sentences).
Custom icon for
type="custom". Ignored for success/error types.Auto-dismiss duration in milliseconds.The notification automatically hides and calls
onClose after this duration.Display manual close button in the top-right corner.Allows users to dismiss notification before auto-close timer.
Callback fired when notification is dismissed (auto or manual).Use this to update parent state and reset visibility.
Custom inline styles for the container.For
type="custom", you must set background color:Features
- Smooth animations: Slide in/out with scale effect
- Auto-dismiss: Configurable timeout for automatic closure
- Manual close: Optional close button for user control
- Type variants: Success, error, and custom types with icons
- Positioning: Bottom-left corner, absolute positioning
- Responsive: Adapts to screen width (max-width constraint)
- Non-blocking: Uses absolute positioning with high z-index
- Accessible: Uses
role="feedback"for semantic identification
Animation Details
Slide In (Enter)
- Duration: 0.3s
- Easing: ease-out
- Effect: Scale from 0 to 1, opacity from 0 to 1
- Transform origin: Bottom-left corner
Slide Out (Exit)
- Duration: 0.3s
- Easing: ease-in
- Effect: Scale from 1 to 0, opacity from 1 to 0
- Transform origin: Bottom-left corner
Design Specifications
Position & Size
- Position: Absolute, bottom-left
- Bottom: 24px from viewport bottom
- Left: 24px from viewport left
- Min width: 40% of screen
- Max width: calc(100% - 24px)
- Width: Fits content
- Z-index: 100
Colors
- Success:
Color.status.color.success(green) - Error:
Color.status.color.error(red) - Custom: User-defined via
style.background - Text: White for all types
- Icon: White for all types
Spacing & Layout
- Padding: 16px
- Border radius: 4px
- Icon margin: 12px right
- Box shadow: Layered shadow for depth
2px 0px 20px rgba(0, 0, 0, 0.09)0px 4px 8px rgba(0, 0, 0, 0.1)
Type-Specific Behavior
Success Type
- ✅ Check icon (from Lucide React)
- Green background
- White text and icon
- Used for: Save confirmations, successful operations
Error Type
- ❌ X icon (from Lucide React)
- Red background
- White text and icon
- Used for: Failed operations, validation errors
Custom Type
- User-provided icon
- User-defined background color
- White text (use
styleto override) - Used for: Info messages, warnings, custom notifications
Best Practices
- Keep messages concise (1-2 short sentences)
- Use success type for positive confirmations
- Use error type for failures requiring attention
- Set appropriate
closeAfterduration:- 2-3s for success messages
- 4-5s for error messages (more time to read)
- 5s+ for important custom messages
- Add
showClosefor error messages (let users dismiss) - Handle
onCloseto reset state properly - Avoid showing multiple feedback messages simultaneously
- Test on mobile devices (check positioning and width)
- Use custom type for neutral/informational messages
Common Patterns
Global Feedback System
Multiple Feedback Types
Accessibility
- Uses
role="feedback"for semantic identification - High contrast colors (white text on colored background)
- Sufficient size for touch targets (close button)
- Auto-dismiss prevents screen clutter
- Manual close option for accessibility tools
- Consider adding:
aria-live="polite"for screen reader announcementsaria-atomic="true"for complete message reading
Browser Support
- Modern browsers with CSS animations support
- Uses CSS keyframes for animations
- Absolute positioning widely supported
- Box shadow for depth effect
Dependencies
- styled-components - Animations and styling
- lucide-react - Check and X icons
- Button component - Close button
- Text component - Message text