Prerequisites
Before using the AppSloth Banner component, make sure you’ve already set up AppSloth in your project.Adding the Banner Component
The AppSloth Banner component allows you to display important messages to your users across your application. These banners can be informational alerts, announcements, or error notifications. Adding the Banner component to your application is simple:Position your Banner component strategically for optimal user visibility. The
most common placement is at the top of your application, just above the
navigation bar.
How It Works
The Banner component provides a simple yet powerful way to display messages to your users:- Automatic Configuration: The component automatically fetches banner configurations from AppSloth’s servers
- Smart Display: The banner remains hidden unless there’s an active banner configured for the current page
- Path-Based Display: Banners only appear on the paths you specify in the dashboard
- User Interaction: If a link is provided, users can click on the banner to navigate to the specified URL
- Multiple Variants: Choose between different styles (info, error) to match the type of message
Creating Banners from the Dashboard
Instead of hardcoding banner configurations in your code, AppSloth allows you to create and manage banners directly from the dashboard:- Navigate to Banners: Log into your AppSloth Dashboard and go to the “Banners” section
- Create New Banner: Click on the “Create Banner” button
- Configure Banner: Set up your banner with the following options:
- Message: The text to display in the banner
- Variant: Choose between “info” (blue) or “error” (red) styling
- Link: Optional URL for when users click the banner
- Path Rules: Configure where the banner should appear:
- Allow List: Paths where the banner should be shown
- Deny List: Paths where the banner should be hidden
- Create, update, or remove banners without deploying code changes
- Instantly publish banners across your application
- A/B test different banner messages to optimize effectiveness
Path-Based Display
The Banner component intelligently handles path-based display rules:- allowedPaths: Show the banner only on these paths (array or comma-separated string)
- excludedPaths: Hide the banner on these paths (array or comma-separated string)
- Path Patterns: Supports both exact paths and regular expression patterns
- Default Behavior:
- If no paths are specified, the banner shows on all pages
- If only
allowedPathsis specified, the banner shows only on those paths - If only
excludedPathsis specified, the banner shows on all paths except those - If both are specified,
excludedPathstakes precedence overallowedPaths
Customization
The Banner component accepts a few props for customizing its appearance:| Prop | Type | Default | Description |
|---|---|---|---|
containerClassName | string | "" | Class name for the container element that wraps all banners |
bannerClassName | string | "" | Class name applied to each individual banner |
variant | ”info” | “error" | "info” | Default variant style for all banners |
variantStyles | Object | - | Custom styles for different variants to override defaults |
Custom Styling Example
variantStyles prop.
Using the BannerComponent Directly
For more advanced use cases, you can also use theBannerComponent directly:
BannerComponent accepts these props:
| Prop | Type | Default | Description |
|---|---|---|---|
message | string | Required | The message to display in the banner |
variant | ”info” | “error" | "info” | Styling variant for the banner |
className | string | "" | Additional CSS classes for styling |
link | string | undefined | URL to navigate to when clicked |
allowedPaths | string[] | string | undefined | Paths on which to show the banner |
excludedPaths | string[] | string | undefined | Paths on which to hide the banner |
variantStyles | Object | - | Custom styles for different variants |
Next Steps
Now that you’ve added AppSloth Banners to your application, explore more features:Feedback
Collect and manage user feedback to improve your product
Inbox
Send targeted in-app messages and alerts to your users
Retention Modal
Collect feedback and present salvage offers when users try to cancel
