Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

75
Views
How add google font into react-stripe-elements

Hi all I have following code

I am trying to add Ralway google font into my stripe element.

I try this:

App.js

    export default function App() {
      const stripePromise = loadStripe("pk_test_FnsOZv49080ssnyO2xn0gCoS");

      const options = {
        elements: {
          fonts: [
            {
              cssSrc:
                "https://fonts.googleapis.com/css2?family=Raleway&display=swap"
            }
          ]
        }
      };
      return (
        <Elements stripe={stripePromise} options={options}>
          <div className="App">
            <PaymentForm />
          </div>
        </Elements>
      );
    }

PaymentForm .js

     const PaymentForm = () => {
      const stripe = useStripe();
      const elements = useElements();
      const stripeStyle = {
        base: {
          fontFamily: "Raleway",
          fontSize: "16px"
        },
        "::placeholder": {
          color: "green"
        }
      };
      return (
        <div>
          <CardNumberElement
            options={{
          style: stripeStyle
            }}
          />

          <CardExpiryElement options={{ style: stripeStyle }} />

          <CardCvcElement options={{ style: stripeStyle }} />
        </div>
      );
    };

But nothing has happened. Please help me figure out how should I change my code.

I looked into following questions ( 1, 2, 3 ) regarding to fonts for react-stripe-elements but no one of them didn't helped me to resolve my problem.

about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

Is the font-family stylesheet loaded from Google Fonts? I think the issue lies with your options variable. There's an extra elements hash which is not necessary. It should instead look like:

const options = {
  fonts: [{
    cssSrc: "https://fonts.googleapis.com/css2?family=Raleway&display=swap"
  }]
};

return (
  <Elements stripe={stripePromise} options={options}>
    <div className="App">
      <PaymentForm />
    </div>
  </Elements>
)
about 4 years ago · Juan Pablo Isaza Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!