码迷,mamicode.com
首页 > 其他好文 > 详细

[React] Styling a React button component with Radium

时间:2016-03-02 06:56:21      阅读:187      评论:0      收藏:0      [点我收藏+]

标签:

React‘s inline styles allow components to stand on their own by not requiring any external CSS. However HTML‘s style attributes don‘t support pseudo selectors like :hover and :active. By using Radium to listen to mouse events we can restore :hover and :active selectors to inline styles.

 

const { render } = ReactDOM
const rootEl = document.getElementById(‘root‘)


const Div = Radium(({children}) => {
  return (
     <div style={style}>
      {children}
    </div>
  );
});

const style = {
  backgroundColor: ‘#07d‘,
  border: ‘none‘,
  borderRadius: 4,
  color: ‘#fff‘,
  padding: ‘5px 20px‘,
  ‘:hover‘: {
    backgroundColor: ‘#08f‘
  }
}


render(<Div>OK</Div>, rootEl)

 

So, just need to wrap the compoment in to Radium() method.

[React] Styling a React button component with Radium

标签:

原文地址:http://www.cnblogs.com/Answer1215/p/5233468.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!