Aphrodite is a library styling React components.

You get all the benefits of inline styles (encapsulation, no build step, no CSS cascade, building up styling with JavaScript instead of a preprocessor language) with all the benefits of CSS (animations and transitions, pseudo-classes, media queries).

Learn how to use Aphrodite to style reusable React components.

  1. import React, { Component } from 'react'
  2. import { StyleSheet, css } from 'aphrodite'
  3.  
  4. const styles = StyleSheet.create({
  5. button: {
  6. backgroundColor: '#1f8dd6',
  7. border: ,
  8. borderRadius: ,
  9. color: '#fff',
  10. outline: ,
  11. padding: ,
  12.  
  13. ':active': {
  14. boxShadow: '2px 2px 2px 1px rgba(0, 0, 0, 0.2)'
  15. },
  16.  
  17. ':hover': {
  18. backgroundColor: '#1cb841'
  19. },
  20. }
  21. })
  22.  
  23. class Button extends Component {
  24. render() {
  25. return (
  26. <button className={css(styles.button)} onClick={this.props.onClick}>
  27. {this.props.children}
  28. </button>
  29. )
  30. }
  31. }
  32.  
  33. export default Button;

[React] Styling React Components With Aphrodite的更多相关文章

  1. 【转】Facebook React 和 Web Components(Polymer)对比优势和劣势

    原文转自:http://segmentfault.com/blog/nightire/1190000000753400 译者前言 这是一篇来自 StackOverflow 的问答,提问的人认为 Rea ...

  2. [React Fundamentals] Composable Components

    To make more composable React components, you can define common APIs for similar component types. im ...

  3. [React] React Router: Named Components

    In this lesson we'll learn how to render multiple component children from a single route. Define a n ...

  4. Facebook React 和 Web Components(Polymer)对比优势和劣势

    目录结构 译者前言 Native vs. Compiled 原生语言对决预编译语言 Internal vs. External DSLs 内部与外部 DSLs 的对决 Types of DSLs - ...

  5. [React] 09 - Tutorial: components

    jsx变为js的过程:http://babeljs.io/repl/ youtube: https://www.youtube.com/channel/UCA-Jkgr40A9kl5vsIqg-BIg ...

  6. 小谈React、React Native、React Web

    React有三个东西,React JS 前端Web框架,React Native 移动终端Hybrid框架,React Web是一个源码转换工具(React Native 转 Web,并之所以特别提出 ...

  7. 重谈react优势——react技术栈回顾

    react刚刚推出的时候,讲react优势搜索结果是几十页. 现在,react已经慢慢退火,该用用react技术栈的已经使用上,填过多少坑,加过多少班,血泪控诉也不下千文. 今天,再谈一遍react优 ...

  8. React 与 React Native 底层共识:React 是什么

    此系列文章将整合我的 React 视频教程与 React Native 书籍中的精华部分,给大家介绍 React 与 React Native 结合学习的方法,此小节主要介绍 React 的底层原理与 ...

  9. 《React Native 精解与实战》书籍连载「React 与 React Native 简介」

    此文是我的出版书籍<React Native 精解与实战>连载分享,此书由机械工业出版社出版,书中详解了 React Native 框架底层原理.React Native 组件布局.组件与 ...

随机推荐

  1. 六款最佳Linux教育应用

    导读 对教育行业的用户来说,有好几款专门的Linux发行版是专门面向教育行业的.本文将介绍适合教育领域的几款顶级发行版. 1.Edubuntu 位居榜首的是Edubuntu.顾名思义,Edubuntu ...

  2. HDU-4861 Couple doubi

    http://acm.hdu.edu.cn/showproblem.php?pid=4861 Couple doubi Time Limit: 2000/1000 MS (Java/Others)   ...

  3. duilib入门之贴图描述、类html文本描述、动态换肤、Dll插件、资源打包

    转载自duilib入门文档 贴图描述: Duilib的表现力丰富很大程度上得益于贴图描述的简单强大.Duilib的贴图描述分为简单模式和复杂模式两种. 简单模式使用文件名做为贴图描述内容,在这种方式下 ...

  4. 一道JAVA经典面试题目的两种解法

    题目要求:String s="-1 2 5 78 129 -65 -23";将字符串进行升序排序后输出. 方法一:使用数组进行排序 思路: 1.获取字符串中的数值:   2.将数组 ...

  5. [CODEVS2603]公路修建

    题目描述 某国有n个城市,它们互相之间没有公路相通,因此交通十分不便.为解决这一“行路难”的问题,政府决定修建公路.修建公路的任务由各城市共同完成.    修建工程分若干轮完成.在每一轮中,每个城市选 ...

  6. Camera图片特效处理综述(Bitmap的Pixels处理、Canvas/paint的drawBitmap处理、旋转图片、裁截图片、播放幻灯片浏览图片<线程固定时间显示一张>)

    一种是直接对Bitmap的像素进行操作,如:叠加.边框.怀旧.(高斯)模糊.锐化(拉普拉斯变换). Bitmap.getPixels(srcPixels, 0, width, 0, 0, width, ...

  7. Spring学习笔记(二)Spring基础AOP、IOC

    Spring AOP 1. 代理模式 1.1. 静态代理 程序中经常需要为某些动作或事件作下记录,以便在事后检测或作为排错的依据,先看一个简单的例子: import java.util.logging ...

  8. Linux重复执行上条命令

    Linux系统下Shell重复执行上条命令的 4 种方法: 1.使用上方向键,并回车执行.2.按 !! 并回车执行.3.输入 !-1 并回车执行.4.按 Ctrl+P 并回车执行.

  9. [git] 更新到某个指定版本

    [git] 更新到某个指定版本 - Vanquisher - 博客频道 - CSDN.NET     [git] 更新到某个指定版本    2015-09-06 09:30 527人阅读 评论(0) ...

  10. centos5 vim升级到7.4

    vim在centos中的版本为7.0,导致很多插件都无法使用,所以想到升级一下. wget ftp://ftp.vim.org/pub/vim/unix/vim-7.4.tar.bz2 tar jvz ...