npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2025 – Pkg Stats / Ryan Hefner

react-native-payment-card-icons

v1.0.3

Published

A collection of high-quality, customizable payment card brand icons (Visa, Mastercard, Maestro, Amex, and more) as React Native SVG components — fully compatible with React Native, Expo, and React Native Web for seamless cross-platform use.

Readme

Table of Contents

Features

  • 🎨 Multiple styles: flat, flatRounded, logo, logoBorder, mono, monoOutline
  • 💳 Comprehensive coverage: Supports 17+ payment providers
  • 📱 Cross-platform: Works with React Native, Expo, and React Native Web
  • 🔧 Fully customizable: Size, color, and styling options
  • 🎯 TypeScript support: Complete type definitions included
  • 📦 Zero dependencies: Only requires react-native-svg

Installation

npm install react-native-payment-card-icons
# or
yarn add react-native-payment-card-icons

Prerequisites

This library requires react-native-svg to be installed and configured in your project:

npm install react-native-svg
# or
yarn add react-native-svg

For React Native 0.60+, run npx pod-install (iOS only) after installation.

Usage

Basic Usage with PaymentIcon Component

The easiest way to use the library is with the PaymentIcon component:

import React from 'react';
import { View } from 'react-native';
import { PaymentIcon } from 'react-native-payment-card-icons';

export default function App() {
  return (
    <View>
      {/* Basic usage */}
      <PaymentIcon type="visa" />

      {/* With custom styling */}
      <PaymentIcon
        type="mastercard"
        variant="flatRounded"
        width={60}
        height={40}
      />

      {/* Monochrome style with custom color */}
      <PaymentIcon
        type="amex"
        variant="mono"
        width={50}
        height={32}
        fill="#007bff"
      />
    </View>
  );
}

Using Individual Icon Components

You can also import and use individual icon components directly:

import React from 'react';
import { View } from 'react-native';
import {
  VisaFlat,
  MastercardLogo,
  AmexMono
} from 'react-native-payment-card-icons';

export default function App() {
  return (
    <View>
      <VisaFlat width={60} height={40} />
      <MastercardLogo width={60} height={40} />
      <AmexMono width={60} height={40} fill="#333" />
    </View>
  );
}

API Reference

PaymentIcon Props

| Prop | Type | Default | Description | |------|------|---------|-------------| | type | PaymentIconType | required | The payment card brand | | variant | PaymentIconStyle | 'flat' | The icon style variant | | width | number \| string | 24 | Icon width | | height | number \| string | 24 | Icon height | | fill | string | undefined | Fill color (mainly for mono variants) |

Supported Payment Types

| Type | Description | |------|-------------| | 'visa' | Visa | | 'mastercard' | Mastercard | | 'amex' | American Express | | 'maestro' | Maestro | | 'discover' | Discover | | 'jcb' | JCB | | 'diners' | Diners Club | | 'unionpay' | UnionPay | | 'elo' | Elo | | 'hiper' | Hiper | | 'hipercard' | Hipercard | | 'mir' | Mir | | 'alipay' | Alipay | | 'paypal' | PayPal | | 'generic-card' | Generic Card | | 'security-code' | Security Code (CVV) | | 'security-code-front' | Security Code Front |

Supported Variants

| Variant | Description | Best Use Case | |---------|-------------|---------------| | 'flat' | Flat design with brand colors | Modern UI, cards display | | 'flatRounded' | Flat design with rounded corners | Card forms, modern UI | | 'logo' | Official brand logo | Marketing, branding | | 'logoBorder' | Logo with border | Professional docs, forms | | 'mono' | Monochrome filled | Custom branded UI | | 'monoOutline' | Monochrome outline | Minimalist UI, wireframes |

Examples

Visual Showcase

The library supports multiple variants for each payment method. Above shows Visa cards in all 6 available styles: flat, flatRounded, logo, logoBorder, mono, and monoOutline.

Live Example App

Expo snack example: https://snack.expo.dev/@lekgwaraj/react-native-payment-card-icons

Dynamic Payment Form

This example shows how to create a dynamic payment form that automatically detects the card type as the user types:

import React, { useState } from 'react';
import { View, TextInput, StyleSheet } from 'react-native';
import { PaymentIcon } from 'react-native-payment-card-icons';

// Simple card type detection (you might want a more robust solution)
const detectCardType = (number: string) => {
  if (number.startsWith('4')) return 'visa';
  if (number.startsWith('5') || number.startsWith('2')) return 'mastercard';
  if (number.startsWith('3')) return 'amex';
  return 'generic-card';
};

export default function PaymentForm() {
  const [cardNumber, setCardNumber] = useState('');
  const cardType = detectCardType(cardNumber);

  return (
    <View style={styles.container}>
      <View style={styles.inputContainer}>
        <TextInput
          style={styles.input}
          placeholder="Card Number"
          value={cardNumber}
          onChangeText={setCardNumber}
          keyboardType="numeric"
        />
        <PaymentIcon
          type={cardType}
          variant="flat"
          width={40}
          height={25}
        />
      </View>
    </View>
  );
}

const styles = StyleSheet.create({
  container: {
    padding: 20,
  },
  inputContainer: {
    flexDirection: 'row',
    alignItems: 'center',
    borderWidth: 1,
    borderColor: '#ddd',
    borderRadius: 8,
    paddingHorizontal: 15,
  },
  input: {
    flex: 1,
    height: 50,
    fontSize: 16,
  },
});

Card Grid Display

Display all supported payment methods in a clean grid layout:

import React from 'react';
import { View, Text, FlatList, StyleSheet } from 'react-native';
import { PaymentIcon } from 'react-native-payment-card-icons';

const supportedCards = [
  { type: 'visa', name: 'Visa' },
  { type: 'mastercard', name: 'Mastercard' },
  { type: 'amex', name: 'American Express' },
  { type: 'discover', name: 'Discover' },
  { type: 'paypal', name: 'PayPal' },
];

export default function SupportedPayments() {
  return (
    <View style={styles.container}>
      <Text style={styles.title}>We Accept</Text>
      <FlatList
        data={supportedCards}
        numColumns={3}
        renderItem={({ item }) => (
          <View style={styles.cardItem}>
            <PaymentIcon
              type={item.type}
              variant="flatRounded"
              width={60}
              height={38}
            />
            <Text style={styles.cardName}>{item.name}</Text>
          </View>
        )}
        keyExtractor={(item) => item.type}
      />
    </View>
  );
}

const styles = StyleSheet.create({
  container: {
    padding: 20,
  },
  title: {
    fontSize: 18,
    fontWeight: 'bold',
    marginBottom: 15,
  },
  cardItem: {
    flex: 1,
    alignItems: 'center',
    margin: 10,
  },
  cardName: {
    marginTop: 8,
    fontSize: 12,
    textAlign: 'center',
  },
});

Custom Themed Icons

Create custom themes for your payment icons to match your app's design:

import React from 'react';
import { View, StyleSheet } from 'react-native';
import { PaymentIcon } from 'react-native-payment-card-icons';

export default function ThemedIcons() {
  return (
    <View style={styles.container}>
      {/* Dark theme */}
      <View style={[styles.section, styles.darkTheme]}>
        <PaymentIcon type="visa" variant="mono" fill="#ffffff" width={50} height={32} />
        <PaymentIcon type="mastercard" variant="mono" fill="#ffffff" width={50} height={32} />
        <PaymentIcon type="amex" variant="mono" fill="#ffffff" width={50} height={32} />
      </View>

      {/* Brand theme */}
      <View style={[styles.section, styles.brandTheme]}>
        <PaymentIcon type="visa" variant="monoOutline" fill="#007bff" width={50} height={32} />
        <PaymentIcon type="mastercard" variant="monoOutline" fill="#007bff" width={50} height={32} />
        <PaymentIcon type="amex" variant="monoOutline" fill="#007bff" width={50} height={32} />
      </View>
    </View>
  );
}

const styles = StyleSheet.create({
  container: {
    padding: 20,
  },
  section: {
    flexDirection: 'row',
    justifyContent: 'space-around',
    padding: 20,
    marginVertical: 10,
    borderRadius: 8,
  },
  darkTheme: {
    backgroundColor: '#333',
  },
  brandTheme: {
    backgroundColor: '#f8f9fa',
    borderWidth: 1,
    borderColor: '#dee2e6',
  },
});

Platform Support

Expo Support

This library works seamlessly with Expo. Make sure you have react-native-svg installed:

expo install react-native-svg

React Native Web Support

The library is fully compatible with React Native Web. No additional configuration required.

TypeScript Support

The library includes complete TypeScript definitions. All component props and types are exported:

import {
  PaymentIcon,
  PaymentIconType,
  PaymentIconStyle,
  PaymentIconProps
} from 'react-native-payment-card-icons';

// Type-safe usage
const cardType: PaymentIconType = 'visa';
const variant: PaymentIconStyle = 'flatRounded';

Performance

  • Optimized SVGs: All icons are optimized for minimal bundle size
  • Tree-shakable: Import only the icons you need
  • No bitmap images: Crisp at any resolution
  • Lightweight: Minimal impact on bundle size

Troubleshooting

Common Issues

Icons not showing:

  • Ensure react-native-svg is properly installed and linked
  • For React Native 0.60+, run npx pod-install on iOS

TypeScript errors:

  • Make sure you're using the correct prop types
  • Update to the latest version of the library

Performance on large lists:

  • Consider using getItemLayout for FlatList performance
  • Use appropriate icon sizes to avoid unnecessary rendering

Contributing

See the contributing guide to learn how to contribute to the repository and the development workflow.

Development

# Clone the repository
git clone https://github.com/julekgwa/react-native-payment-card-icons.git

# Install dependencies
yarn install

# Run tests
yarn test

# Run the example app
yarn example ios
# or
yarn example android

License

MIT © Junius Lekgwara

Acknowledgments