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. C++ STL算法系列1---count函数

    一.count函数 algorithm头文件定义了一个count的函数,其功能类似于find.这个函数使用一对迭代器和一个值做参数,返回这个值出现次数的统计结果. 编写程序读取一系列int型数据,并将 ...

  2. again

    建立一个IPC连接: net use \\192.168.0.5\ipc$ "123456" /u:administrator

  3. bzoj 1025 [SCOI2009]游戏(置换群,DP)

    [题目链接] http://www.lydsy.com/JudgeOnline/problem.php?id=1025 [题意] 给定n,问1..n在不同的置换下变回原序列需要的不同排数有多少种. [ ...

  4. Tkinter教程之Scrollbar篇

    本文转载自:http://blog.csdn.net/jcodeer/article/details/1811319 '''Tkinter教程之Scrollbar篇'''#Scrollbar(滚动条) ...

  5. 关于自然常数e的理解

    关于自然常数\(e\)的理解 By Z.H. Fu 切问录 ( http://www.fuzihao.org ) 利息增长模型 在上中学学习对数的时候,我们就学到了一个叫做e的东西(\(e\appro ...

  6. Android应用性能优化笔记(java代码优化)

    Java代码优化  缓存结果:  如果计算代价过高,最好把过去的结果缓存起来. 伪代码如下: result=cache.get(n);        //输入参数n作为键 if(result==nul ...

  7. linux vim用法总结

    1.跳转到指定行 编辑模式下:输入  ngg或nG(n代表行数) 命令模式下:输入  :n(n代表行数) 2.查找命令 命令模式下输入 / 后面加上查找的内容 例如    :/name     (查找 ...

  8. Codeforces 380 简要题解

    ABC见上一篇. 感觉这场比赛很有数学气息. D: 显然必须要贴着之前的人坐下. 首先考虑没有限制的方案数.就是2n - 1(我们把1固定,其他的都只有两种方案,放完后长度为n) 我们发现对于一个限制 ...

  9. HDU5071 - Chat(STL模拟)

    题目描述 略... 题解 现场赛的时候真是脑残...用splay去写..写完发现调试不出来...然后才发现数据范围才5000...不过那时候只有40分钟了..用数组模拟了速度敲了一发.写完只剩10几分 ...

  10. 在Heroku上部署MEAN

    说明:个人博客地址为edwardesire.com,欢迎前来品尝. Heroku是国外普遍使用大受好评的PaaS,支持Nodejs,基础服务(Nodejs+MongoDB)基本都是免费的.搭建MEAN ...