question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

The colorScheme props doesn't apply to Link component

See original GitHub issue

🐛 Bug report

When supplying a colorScheme to a <Link> component, as described in the documentation, the color does not seem to change. This can only be done by setting the color prop to a specific color key value.

💥 Steps to reproduce

  1. Go to your documentation: https://chakra-ui.com/docs/components/link
  2. Try to change the color scheme of the first example, like such: <Link colorScheme="red">Hello world</Link>
  3. Nothing happens

💻 Link to reproduction

See previous

🧐 Expected behavior

I’d expect the color to change, as well as have a hover color set that’s different from the main color

🧭 Possible Solution

I’m not quite sure where this should be added - I’m guessing the layout package?

🌍 System information

Software Version(s)
Chakra UI 1.0.3
Browser Brave 1.18.75
Operating System MacOS 11.0.1

📝 Additional information

  • None

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Reactions:1
  • Comments:5 (5 by maintainers)

github_iconTop GitHub Comments

4reactions
dodascommented, Jan 12, 2021

Hey @cereallarceny.

This probably won’t be implemented in Chakra’s default theme. We can improve the docs to clarify that - either some note, or completely omit those props from Link’s prop table.

However, you can extend the theme and implement it yourself:

export const theme = extendTheme({
  components: {
    Link: {
      variants: {
        // you can name it whatever you want
        primary: ({ colorScheme = "blue" }) => ({
          color: `${colorScheme}.500`,
          _hover: {
            color: `${colorScheme}.400`,
          },
        }),
      },
      defaultProps: {
        // you can name it whatever you want
        variant: "primary",
      },
    },
  },
})

and use it like this:

<Link colorScheme="purple" href="https://google.com">
  This is a purple link
</Link>
3reactions
cereallarcenycommented, Jan 12, 2021

THAT makes more sense. I expected that prop to exist due to incorrect docs. I’ll close this issue now.

Read more comments on GitHub >

github_iconTop Results From Across the Web

How can I change the color of a Link in React with Material-UI?
When I apply the secondary color to the Button, it doesn't take effect. In other components it does work this way. <AppBar position='fixed'>...
Read more >
Theming - Material UI - MUI
The theme specifies the color of the components, darkness of the surfaces, level of shadow, appropriate opacity of ink elements, etc. Themes let...
Read more >
Link - Chakra UI
Props#. The Link component composes the Box component. colorScheme. Description. Color Schemes for Link are not implemented in the default theme.
Read more >
Themes - React Navigation
Themes allow you to change the colors of various components provided by React Navigation. You can use themes to: Customize the colors match...
Read more >
Error when calling theme Props in component using ReactJs ...
I need to pass the color of a theme to a component, I'm using type script (I'm a ... can I use the...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found