0.1.6 • Published 2 years ago
react-card-brand v0.1.6
React Card Brand
A zero-dependency React Hook to show and get the brand from a card type.
Installation
$ npm i -S react-card-brand
or install with Yarn if you prefer:
yarn add react-card-brand
Usage
You can import useCardBrand
into your component and use the getSvgProps
callback to get a current brand from your card type.
import React from 'react';
import { useCardBrand, images } from 'react-card-brand';
export default function Example() {
const { getSvgProps } = useCardBrand();
return (
<div>
<svg {...getSvgProps({ type: 'visa', images })} />
</div>
);
}
Get the brand from a card number
You can use the getCardType
function to get the brand from a card number.
import React from 'react';
import { useCardBrand, images } from 'react-card-brand';
export default function Example() {
const { getSvgProps, getCardBrand } = useCardBrand();
const type = getCardBrand('4242424242424242');
return (
<div>
<svg {...getSvgProps({ type, images })} />
</div>
);
}
Community
All feedback and suggestions are welcome!
License
This is a open-source software licensed under the MIT license
0.1.2
2 years ago
0.1.1
2 years ago
0.1.4
2 years ago
0.1.3
2 years ago
0.1.6
2 years ago
0.1.5
2 years ago
0.1.0
5 years ago
0.1.0-beta.4
5 years ago
0.1.0-beta.3
5 years ago
0.1.0-beta.2
5 years ago
0.1.0-beta.1
5 years ago