Open spherop opened 7 years ago
The above sample code assumes you're generating your html pages with React.js e.g. Gatsby. If you're not, then you'll need to add the CSS some other way. When you create a typography object, it has a toString
method which will generate and print out CSS. <TypographyStyle />
is just wrapping toString
.
Ideally you inline the typography css in the <head>
of your site but you can also just write it out as a .css
file and build it in with the rest of your CSS.
Thanks for the help. I will poke around a little more to see how things can work in the context of my React app. The attraction for me was super simple the drop in option for testing different styles for the site as a whole.
Oh also if your app is a purely clientside single page app, you can also
run typography.injectStyles()
upon loading the app. That injects the
styles in the head. Just make sure to do this before the initial render of
React.
On Mon, Mar 6, 2017 at 11:28 AM Dan Newman notifications@github.com wrote:
Thanks for the help. I will poke around a little more to see how things can work in the context of my React app. The attraction for me was super simple the drop in option for testing different styles for the site as a whole.
— You are receiving this because you commented.
Reply to this email directly, view it on GitHub https://github.com/KyleAMathews/typography.js/issues/105#issuecomment-284504893, or mute the thread https://github.com/notifications/unsubscribe-auth/AAEVh34VN0787d6tO7tcClMixngDTzM4ks5rjF51gaJpZM4MTT05 .
Ok cool - looking forward to trying that... My app is Rails/Webpack/React ...Rails is used at this point only for db/auth and delivering the basic application.html page which react is injected into.
Having trouble understanding how the react components in your example are being added to the
head
?In my app the
head
is inside anindex.html
page - not a react component. My React application code is being added to the body a laCan one add the typography React components in the head via ReactDOM.render?
Any help appreciated.