Search code examples
reactjsbarcode

Changing react barcode format


I am currently using the react-barcode package. It is currently using the format="CODE128" format, I needed to change it to use the Code 39 Barcode Font. How to I import the font to my react project and use it in the react-barcode component. If its not possible is there any other components I can use to achieve this.

Code:

import React, { Component } from 'react';
import Barcode from 'react-barcode';

 class Posts extends Component { 
     render () {
         return (
           <div>
               <Barcode value="http://github.com/kciter" />
           </div>
         );
     }
 }

 export default (Posts);

Display of the code128 barcode


Solution

  • React-barcode doesn't use a barcode font at all.

    You can just, following the docs, set format="CODE39".

    <Barcode value="123456" format="CODE39" />