0
var Mynav = React.createClass({
    render:function(){
        return(
            <div /*style="font-size:100px;"*/>this is my nav bar</div>
        );
    }
});

React.render(<Mynav />,document.getElementById('nav'));

How can i write in the meaning of /*style="font-size:100px;"*/ ?

2 Answers 2

1

You pass an object to the style prop:

style={{fontSize: '100px'}}

Properties are named exactly like the style object of DOM elements.

See the React documentation for more information.

Sign up to request clarification or add additional context in comments.

1 Comment

Super minor but you don't actually need the 'px' you can just do {{fontSize: 100}}.
0

A simple example that does some dynamic styling based on a state would look like this:

style={{
   fontWeight: 'bold',
   color: this.state.active ? 'green' : 'red',
}}

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.