#vane-elements-font
1 messages · Page 1 of 1 (latest)
Did you pass in a CssFontSource or CustomFontSource to the elements.fonts array as well?
https://stripe.com/docs/js/elements_object/create#stripe_elements-options-fonts
Ah, that I'm not sure about
elements.fonts = {
family: 'Poppins',
src: 'url(localhost/sources/Poppins-Regular.ttf)',
}
I tried this, not working
Let me check if I have a colleague who can confirm how/why this might not be working
Hello! I think you're just trying to put the font information in the wrong place. Can you give this a try?
var elements = stripe.elements({
fonts: [
{
family: 'Poppins',
src: 'url(http://localhost/sources/Poppins-Regular.ttf)',
},
]
});
(Made a quick edit to the font URL).
So the fonts property in the Elements options allows you to specify custom fonts, but you have to specify where you want them to be used as well.
it looks similar though, so, I can't tell if its applying or not.
how would I specify where?
See the snippet here: https://stripe.com/docs/stripe-js/appearance-api#variables
Getting closer!
const appearance = {
theme: 'night',
variables: {
colorDanger: "rgb(255, 59, 59)",
colorSuccess: "rgb(29, 179, 7)",
colorPrimary: "rgb(29, 179, 7)",
colorBackground: "rgb(39, 39, 43)",
fontFamily: "Poppins",
},
fonts: [
{
family: 'Poppins',
src: 'url(http://localhost/sources/Poppins-Regular.ttf)',
}
]
};
No, fonts does not go inside appearance.
fonts goes alongside appearance: https://stripe.com/docs/js/elements_object/create
I'm starting to think this is the applied version despite html saying other font families
since now its just looking like this.
It might be an issue with the font being hosted locally. Can you try the Google Fonts URL instead?
const fonts = [
{
cssSrc: "https://fonts.googleapis.com/css2?family=Poppins:wght@500&display=swap"
}
]
// Set up Stripe.js and Elements to use in checkout form, passing the client secret obtained in step 2
const elements = stripe.elements({clientSecret,appearance, fonts});
tried this, looks like this
im pretty sure its applying it, and if not then like this it looks fine
I'll just change the weight and it'll look good
Just tested this and it works:
const elements = stripe.elements({
clientSecret: '<?php echo $paymentIntent->client_secret; ?>',
fonts: [
{
cssSrc: 'https://fonts.googleapis.com/css2?family=Poppins&display=swap',
},
],
appearance: {
theme: 'stripe',
variables: {
fontFamily: 'Poppins',
},
},
});