how to add classes in react
i want to add classes to link tag but im not able to do it.. help
8 Replies
classname attribute is already occupied, thats why
Stack Overflow
How do I add an active class to a Link from React Router?
I've created a bootstrap-style sidebar using Link. Here is a snippet of my code:
<ul className="sidebar-menu">
<li className="header">MAIN NAVIGATION</li>
<li><Link ...
Depending on what you want to do here, you might find the
:local-link
pseudo-class useful to be able to do styling directly in the CSS without needing to change the class name in Reactthe part between
{}
is just a javascript expression. You can use a template string:
or an array if you don't like template strings:
In react you use className, with the camelCase.
classname without the capital letter is html, so react uses className.
thanks for the help guys:thumbup:
Better method is to use the aria attribute vs using a class.
Ben Myers
Style with Stateful, Semantic Selectors
See how building with accessible semantics from the get-go can give you expressive, meaningful style hooks for free.