Docyrus

RateLimitBanner

Animated banner for displaying API rate limiting and circuit breaker states with retry countdown.

iOSAndroid
Preview RateLimitBanner on your device

Scan with Expo Go

Download Expo Go, then scan the QR code to preview native components.

Installation

pnpm dlx @docyrus/cli add @docyrus/rn-rate-limit-banner
Required Packages(2 packages)
pnpm add react-native-reanimated react-native-safe-area-context

Usage

import { RateLimitBanner } from '@/components/docyrus-native/rate-limit-banner';

<RateLimitBanner
  visible={isBlocked}
  blockReason="rate_limited"
  retryAfterSeconds={retryAfter}
  onRetry={() => retryRequest()}
  onDismiss={() => setBlocked(false)}
/>
<RateLimitBanner
  visible={isBlocked}
  mode="modal"
  blockReason="circuit_open"
  retryAfterSeconds={30}
  onRetry={() => retryRequest()}
  onReload={() => reloadApp()}
/>

Toast mode

<RateLimitBanner
  visible={isBlocked}
  mode="toast"
  blockReason="rate_limited"
  retryAfterSeconds={5}
  onDismiss={() => dismiss()}
/>

API Reference

PropTypeDefaultDescription
visibleboolean—Whether the banner is visible
blockReason'rate_limited' | 'circuit_open''rate_limited'Why the request was blocked
retryAfterSecondsnumber0Seconds remaining before retry is allowed (0 = ready)
mode'banner' | 'modal' | 'toast''banner'Display mode
rateLimitTitlestring'Too Many Requests'Title when rate limited
rateLimitMessagestring'Please slow down...'Message when rate limited
circuitOpenTitlestring'Service Temporarily Unavailable'Title when circuit is open
circuitOpenMessagestring'We are experiencing issues...'Message when circuit is open
retryButtonTextstring'Try again'Retry button label
reloadButtonTextstring'Reload App'Reload button label
showReloadButtonbooleantrueShow reload action button
autoHideDelaynumber2000Auto-hide delay after recovery (ms), 0 to disable
onRetry() => void—Retry button handler
onReload() => void—Reload button handler
onDismiss() => void—Dismiss/close handler
classNamestring—Additional CSS classes

Display Modes

ModeDescription
bannerFull-width top banner with slide-in animation. Shows title, message, countdown, retry and reload buttons.
modalCentered modal overlay with icon, title, message, countdown badge, and action buttons.
toastBottom floating toast with compact layout, title, countdown, and dismiss button.

Type Exports

TypeDescription
RateLimitBannerPropsProps for RateLimitBanner component
RateLimitBannerMode'banner' | 'modal' | 'toast'
RateLimitBlockReason'rate_limited' | 'circuit_open'

On this page