[React] Styling a React button component with Radium
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的更多相关文章
- [React] Styling React Components With Aphrodite
Aphrodite is a library styling React components. You get all the benefits of inline styles (encapsul ...
- [React Native] Using the Image component and reusable styles
Let's take a look at the basics of using React Native's Image component, as well as adding some reus ...
- React.Component 与 React.PureComponent(React之性能优化)
前言 先说说 shouldComponentUpdate 提起React.PureComponent,我们还要从一个生命周期函数 shouldComponentUpdate 说起,从函数名字我们就能看 ...
- [React] Refactor a Stateful List Component to a Functional Component with React PowerPlug
In this lesson we'll look at React PowerPlug's <List /> component by refactoring a normal clas ...
- 十九、React UI框架Antd(Ant Design)的使用——及react Antd的使用 button组件 Icon组件 Layout组件 DatePicker日期组件
一.Antd(Ant Design)的使用:引入全部Css样式 1.1 antd官网: https://ant.design/docs/react/introduce-cn 1.2 React中使用A ...
- React.createClass 、React.createElement、Component
react里面有几个需要区别开的函数 React.createClass .React.createElement.Component 首选看一下在浏览器的下面写法: <div id=" ...
- [React] Use React.memo with a Function Component to get PureComponent Behavior
A new Higher Order Component (HOC) was recently released in React v16.6.0 called React.memo. This be ...
- React源码 React.Component
React中最重要的就是组件,写的更多的组件都是继承至 React.Component .大部分同学可能都会认为 Component 这个base class 给我们提供了各种各样的功能.他帮助我们去 ...
- React.Component 和 React.PureComponent 、React.memo 的区别
一 结论 React.Component 是没有做任何渲染优化的,但凡调用this.setState 就会执行render的刷新操作. React.PureComponent 是继承自Componen ...
随机推荐
- telnet IP不通/sybase central工具无法连接到数据库
问题描述:客户端sybase central工具无法连接到数据库 服务端操作系统:RHEL5.8_x64,安装sybase-ASE15.7,端口号4112 IP:192.168.1.220 hos ...
- indexOf()忽略大小写方法
indexOf() 方法可返回某个指定的字符串值在字符串中首次出现的位置.如果没有出现,则输出-1. indexOf() 方法对大小写敏感!所以要检索字符串且忽略大小写的时候,可以先把字符串转换成全部 ...
- Activity-在ListFragment中为ListView增加空白视图
有两种方法可以实现为ListView添加空白视图.但是原理都一样: 第一种方法是XML+代码添加: 1.定义emptyView视图 2.调用AdapterView的setEmptyView(empt ...
- SQL Server 2005中的分区表(三):将普通表转换成分区表
在设计数据库时,经常没有考虑到表分区的问题,往往在数据表承重的负担越来越重时,才会考虑到分区方式,这时,就涉及到如何将普通表转换成分区表的问题了. 那么,如何将一个普通表转换成一个分区表 呢?说到底, ...
- oracle学习笔记(一)用户管理
--oracle学习第一天 --连接 @后面连接数据库实例,具体连接到那个数据库 conn scott/tiger@MYORA1; --修改密码 passw; --显示用户 show user; -- ...
- Oracle System密码忘记 密码修改、删除账号锁定lock
一下转自http://www.cnblogs.com/yjhrem/articles/2340149.html 运行cmd命令行 录入 sqlplus /nolog 无用户名登录 conn /as ...
- 二维码生成 - QrCodeNet
下载QrCodeNet /// <summary> /// 生成QR码 /// </summary> /// <param name="output_path& ...
- Bootstrap新手常见问题
题记 bootstrap这个开源的UI库确实很方便,用了两日,觉得不错,但也有些问题比较头疼! 主题 1.怎么使用?怎么定制?下面是一个范例,修改了navbar的颜色,重新设置了select控件的默认 ...
- C#检测串口被拔掉等一些触发事件合集
// //设备异常重载 // protected override void WndProc(ref Message m) { if (m.Msg == 0x0219) {//设备被拔出 if (m. ...
- 如何禁止C++默认生成成员函数
前言: 前几天在一次笔试过程中被问到c++如何设计禁止调用默认构造函数,当时简单的想法是直接将默认构造函数声明为private即可,这样的话对象的确不能直接调用.之后查阅了<Effective ...