Theme-ui: Styling react-router-dom Link components

Created on 20 Nov 2019  路  2Comments  路  Source: system-ui/theme-ui

It is very easy to style react-router's Link components via sx. But how do I make sure that they look the same as the links (a elements) generated by MDX (they are using the specifications from my theme).

Is this the best way to do it?

/** @jsx jsx */
import { jsx } from 'theme-ui';
import { Link } from 'react-router-dom';

function MyComponent(props) {
  return <Link to="/" sx={theme => theme.styles.a}>somewhere</Link>;
}

Most helpful comment

You can use variants for this, e.g. <Link sx={{ variant: 'styles.a' }} /> - alternatively you can use Styled.a with the as prop: <Styled.a as={ReachLink} />

All 2 comments

You can use variants for this, e.g. <Link sx={{ variant: 'styles.a' }} /> - alternatively you can use Styled.a with the as prop: <Styled.a as={ReachLink} />

Thank you.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

vojtaholik picture vojtaholik  路  3Comments

moshemo picture moshemo  路  3Comments

LeunensMichiel picture LeunensMichiel  路  3Comments

george-norris-salesforce picture george-norris-salesforce  路  3Comments

chibicode picture chibicode  路  3Comments