Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

RaisedButton wrapped in Link from react-router have CSS issues #2485

Closed
Antonhansel opened this issue Dec 11, 2015 · 11 comments
Closed

RaisedButton wrapped in Link from react-router have CSS issues #2485

Antonhansel opened this issue Dec 11, 2015 · 11 comments
Labels
bug 🐛 Something doesn't work

Comments

@Antonhansel
Copy link

I'm not sure if this should also be posted on react-router.

Using the following toolbar configuration:

        <ToolbarGroup key={1} float="right">
          <ToolbarSeparator/>
        <Link to="/dashboard"><RaisedButton label="Dashboard" primary={true}/></Link>
        <Link to="/clients"><RaisedButton label="Clients" primary={true}/></Link>
        <RaisedButton label="Logout" primary={false} onClick={this.logout}/>
        </ToolbarGroup>

screen shot 2015-12-11 at 19 37 49

As you can see, when wrapped into Link from react-router the CSS is wrong.

Should I wrap it another way?

Thank you for your great work on this awesome library.

@Antonhansel Antonhansel changed the title RaisedButton wrapped in react-router have CSS issues RaisedButton wrapped in Link from react-router have CSS issues Dec 11, 2015
@alitaheri alitaheri added the bug 🐛 Something doesn't work label Dec 12, 2015
@alitaheri
Copy link
Member

ToolbarGroup passed style down to it's children. but since it's immediate child is Link the RaisedBottom is not receiving the props. can you use something else and try again?

@kai23
Copy link

kai23 commented Jan 8, 2016

I have the same issue. Did you find any trick to bypass it ?

@mbrookes
Copy link
Member

mbrookes commented Jan 8, 2016

It looks like ReactRouter Link consumes the style prop: https://github.com/rackt/react-router/blob/master/modules/Link.js#L69

@kai23
Copy link

kai23 commented Jan 11, 2016

Hmm… that's annoying. Don't we have any way to make it more "important" ? Or can we add default material-ui styles to Link ?

@salfej
Copy link

salfej commented Feb 19, 2016

Try:

<RaisedButton linkbutton containerElement={<Link to="/dashboard" />} label="Dashboard" primary={true}/> <RaisedButton linkbutton containerElement={<Link to="/clients" />} label="Clients" primary={true}/>

The containerElement seems to do the trick of keeping alignment and changing states.

@mbrookes
Copy link
Member

Thanks @salfej We need to document that.

#850

@tintin1343
Copy link
Contributor

@mbrookes : I guess this can be closed now.

@nomadtechie
Copy link

nomadtechie commented Jul 5, 2016

@mbrookes is there any way we can add the containerElement to the ToolbarTitle component as well? It's fairly easy to make your own title with the material styling however, it would be more consistent to add it into the library. Thoughts? I can create a new issue if you agree.

@CoachThomLamb
Copy link

ok ... sorry but I can't get this to work ?

@brettwise
Copy link

The trick here seems to be using the containerElement property on your button @WillowHQ. Seems to resolve the CSS issue I was seeing on the <FlatButton /> component I was using.

@salfej tip seems to be working.

@MR-R0b0t0
Copy link

I know this issue has been closed by I am also facing similar issues using the <RaisedButton /> component with react-router's <Link /> to. My button is no longer aligned with the <AppBar />'s Title. See screenshot below:

screen shot 2017-02-10 at 4 04 24 pm

This is my code:

const LogIn = () => (
    <RaisedButton containerElement={<Link to="/login" />} label="login" primary={true} />
)


export class TopNav extends React.Component {
  constructor(props) {
    super(props)
  }

  render() {
    const isLoggedIn = this.props.isLoggedIn;
    return (
      <div>
        <AppBar
          title="FitFights"
          iconElementRight={isLoggedIn ? <LoggedIn /> : <LogIn />}
          showMenuIconButton={false}
        />
      </div>
    )
  }
}

Any ideas?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug 🐛 Something doesn't work
Projects
None yet
Development

No branches or pull requests

10 participants