Skip to main content

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:
  1. Automatic Configuration: The component automatically fetches banner configurations from AppSloth’s servers
  2. Smart Display: The banner remains hidden unless there’s an active banner configured for the current page
  3. Path-Based Display: Banners only appear on the paths you specify in the dashboard
  4. User Interaction: If a link is provided, users can click on the banner to navigate to the specified URL
  5. 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:
  1. Navigate to Banners: Log into your AppSloth Dashboard and go to the “Banners” section
  2. Create New Banner: Click on the “Create Banner” button
  3. 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
This dashboard approach gives you several advantages:
  • Create, update, or remove banners without deploying code changes
  • Instantly publish banners across your application
  • A/B test different banner messages to optimize effectiveness
AppSloth Banner Dashboard

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 allowedPaths is specified, the banner shows only on those paths
    • If only excludedPaths is specified, the banner shows on all paths except those
    • If both are specified, excludedPaths takes precedence over allowedPaths
All of these rules can be configured directly from the AppSloth dashboard without touching your code.

Customization

The Banner component accepts a few props for customizing its appearance:

Custom Styling Example

You can override these styles partially or completely using the variantStyles prop.

Using the BannerComponent Directly

For more advanced use cases, you can also use the BannerComponent directly:
The BannerComponent accepts these props:

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