Link as styled component
See original GitHub issueI followed #799 but couldn’t get a clean way to have a styled-component link, I had to duplicate the href:
const StyledLink = styled.a`
color: red;
background: blue;
`
export default ({ href, name }) => (
<Link prefetch href={href}>
<StyledLink href={href}>{name}</StyledLink>
</Link>
)
What’s the proper way to make styled-component links?
Using next.js 2.3.1.
Issue Analytics
- State:
- Created 6 years ago
- Reactions:3
- Comments:18 (5 by maintainers)
Top Results From Across the Web
How to style React Router links with styled-components
Using styled-components helps you keep track of which components are rendered on a page and injects only those components' styles. When combined ...
Read more >How to style your React-Router links using styled-components
METHOD 2: Styling links using 'styled. If you are familiar with styled components, you should know that styled is like the very basic...
Read more >Styling a Router Link with styled-components - Stack Overflow
What is the best way to style the Link using the styled-components library in the code that follows. I can find lots of...
Read more >Basics - styled-components
styled -components utilises tagged template literals to style your components. It removes the mapping between components and styles. This means that when you're ......
Read more >Style active state of Links in Styled Components - Medium
A Styled Component passes all HTML attributes if it is a simple element, like a div or button or ..., and all props...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Hey guys. At version
3.0.1-beta.13+
, you could set passHref toLink
(as a boolean property) to expose itshref
tostyled-components
(or any other library that wraps its<a/>
tag).Using the first example of issue: it could be done this way:
You can pass a component to styledcomponents instead of using a tag https://github.com/styled-components/styled-components#third-party-components
Use it