In the react application I developed, I generally use the ubuntu font. I just want to use nunito font for login and register page. As an example, I showed my login page. I want to change all kinds of text styles such as form items, buttons, titles (h1) in this card, how can I do this?
return (
<div className="centerItems login">
<Button
className="back-to-home"
href="https://www.example.com/"
type="default"
icon={<HomeOutlined />}
size={"medium"}
/>
<Card className="login-card">
<div className="centerItems">
<Image preview={false} width={200} src={logo} />
<h1 style={{ marginBottom: 8 }}>Login</h1>
</div>
<div className="login-form">
<LoginForm className="centerItems" />
</div>
</Card>
</div>
);
3
Answers
you will need to import css file how many fonts, you want to use. example add multiple fonts
I chose three fonts. and you can add to apply html
if you want to apply body tag
and at your root App component. make a fun to add based on the url here is my example
No need to write any scripts.
You can do it with CSS alone. Since you have the
.login
class in the wrapper ensure that you also have the unique class name in the register form and then you can add the CSS like this,[OR]
If you can able to add class in the tag itself by using router logic based on which page you currently are then you can add the
font-family
to thebody
tag with the class name you added. like thisConsider that class name I added using router logic to body is
nunito-font
There are two ways to achieve what you want.
I’m going to be assuming your loginpage component file is "LoginPage.js"
Since the methods for both loginpage and registerpages are the same I’m only going to show how to do it for the loginpage.
By importing induvidual css files
import './LoginPage.css
( Assuming the css file is in the same page as the LoginPage.js )Here is an example
In your LoginPage.js, return something like this –
And in your LoginPage.css –
By giving your component a className
When you call your component in your main file, add a className to it like so –
Then style it in your main css file using the className "LoginPage-container" ( Like in the last example )