index.css
@font-face{
font-family:"Bauhaus";
src:local('BAUHS'),
url('./BAUHS.ttf') format('truetype');
}
I want to use the "Bauhaus" font in my react component index.js file based on certain condition. Could you please help how to use it.
Here is my code:
import './index.css';
class NameForm extends React.Component {
constructor(props) {
super(props);
this.state = {fontFamilyName: ''};
this.handleChange = this.handleChange.bind(this);
}
handleChange(event) {
this.setState({fontFamilyName: event.target.value});
}
render() {
return (
<div>
<select onChange={this.handleChange}>
<option value='Arial'>Arial</option>
<option value='Bauhaus'>Bauhaus</option>
<option value='Times New Roman'>Times New Roman</option>
</select>
<p style={{fontFamily:this.state.fontFamilyName}}>Some Text here</p>
</div> );
}
}
optionlikevalue='Arial'.