I’m new to react and I have the function component which is a Facebook sign in button but I don’t know how to style it,is there a way to style a signin button by facebook or google?
here is the code for (facebooklogin.js):
import React from "react";
import {LoginSocialFacebook} from "reactjs-social-login";
import {FacebookLoginButton} from "react-social-login-buttons";
import {useState} from 'react';
import styled from "styled-components";
function FacebookLogin() {
const [profile, setProfile] = useState(null);
return(
<div>
{!profile ? <LoginSocialFacebook
appId="922883705581488"
onResolve={(response) => {
console.log(response);
setProfile(response.data);
}}
onReject={(error) => {
console.log(error);
}}
>
<FacebookLoginButton />
</LoginSocialFacebook>: ''}
{profile ? <div>
<h1>{profile.name}</h1>
<img src={profile.picture.data.url} />
</div>: ''}
</div>
);
}
export default FacebookLogin
the code for (App.js):
import FacebookLogin from "./Components/facebooklogin";
import GoogleLogin from "./Components/GoogleLogin";
import { Component } from "react";
import styled from "styled-components";
import './App.css';
class App extends Component {
render(){
return (
<div className="App">
<FacebookLogin></FacebookLogin>
</div>
);
}
}
export default App;
I tried style it through a class name but did not work
2
Answers
It seems you are using a package for the buttons.
According to the docs, you can create your own button component and apply your styles. For example, to recreate a
<FacebookLoginButton/>
you can do:Then simply use it as:
I tried this library. I found 3 approaches.
I’ve also added the code here: https://codesandbox.io