TypeStyle is the only current CSS in JS solution that is designed with TypeSafety and TypeScript developer ergonomics in mind.

In this lesson we will show how easy it is to setup with zero configuration and also demonstrate its UI framework agnostic nature. We will also show how to integrate it with your application framework of choice using ReactJS as an example.

Install:

npm install --save typestyle

Using:

import { style } from 'typestyle';
import * as React from 'react';
import * as ReactDOM from 'react-dom'; const className = style({
color: 'red',
background: 'yellow'
}); ReactDOM.render(
<div className={className}>
Hello Typestyle
</div>,
document.getElementById('root')
);

It generate unqiue class name:

.fdulqt6 {
background: yellow;
color: red;
}
<div data-reactroot="" class="fdulqt6">Hello Typestyle</div>

[TypeStyle] Add type safety to CSS using TypeStyle的更多相关文章

  1. 解决Type safety: The expression of type List needs

    解决Type safety: The expression of type List needs unchecked conversion to conform to 在方法前加上这句话就可以了@Su ...

  2. [TypeScript] Increase TypeScript's type safety with noImplicitAny

    TypeScript tries to infer as much about your code as it can. But sometimes there really is not enoug ...

  3. [TypeStyle] Add responsive styles using TypeStyle Media Queries

    Media queries are very important for designs that you want to work on both mobile and desktop browse ...

  4. [TypeStyle] Load raw CSS in TypeStyle

    TypeStyle tries to be an all in one CSS in JS management solution so you can always fall back to raw ...

  5. 给 input 中 type="text" 设置CSS样式

    input[type="text"], input[type="password"] {    border: 1px solid #ccc;    paddi ...

  6. Type Safety and Type Inference

    Swift is a type-safe language. A type safe language encourages you to be clear about the types of va ...

  7. CSS:给 input 中 type="text" 设置CSS样式

    input[type="text"], input[type="password"] {    border: 1px solid #ccc;    paddi ...

  8. java中的类型安全问题-Type safety: Unchecked cast from Object to ...

    首先,java语言室类型安全的,通常我们遇到这个问题是出现在Object转化为目标类型时, 这个转化并不是安全的.这个问题普遍认为因为使用了jdk1.5或者1.6的泛型, request.getAtt ...

  9. Type safety: Unchecked cast from Object to ArrayList

    表明Object转化为ArrayList这个转化并不是安全的.. 编译的时候需要加入修饰符才能正常编译(具体是那个修饰符..不记得了.^_^),否则会提示有警告 当然这只是一个警告,如果楼主自信这个转 ...

随机推荐

  1. syslog日志介绍

    一. syslog简介 syslog是一种工业标准的协议,可用来记录设备的日志.在UNIX系统,路由器.交换机等网络设备中,系统日志(System Log)记录系统中任何时间发生的大小事件.管理者可以 ...

  2. Android学习笔记进阶九之Matrix对称变换

    网上很多的倒影特效实际上就是一个对称变换,在改变透明度即可. Matrix对称变换包括很多种,有关于Y轴对称,关于X轴对称,关于y= -x对称等等. 1 关于Y轴对称 // 获取资源文件的引用res ...

  3. 35.Intellij IDEA设置忽略部分类编译错误

    转自:https://www.aliyun.com/jiaocheng/290360.html 有些时候我们的项目中有些错误,但这些错误并不影响项目的整体运行(或许是没有使用到),默认情况下idea是 ...

  4. javascript 幻灯片代码(含自动播放)

    HTML <div class="slideshow-container"> <div class="mySlides fade"> & ...

  5. 洛谷 P3654 First Step (ファーストステップ)

    洛谷 P3654 First Step (ファーストステップ) https://www.luogu.org/problemnew/show/P3654 题目描述 可是……这个篮球场,好像很久没有使用过 ...

  6. 【SonicUI】关于字体高亮的问题。。

    m_pSonicString[1]->Format(_T("/c=%x, a='http://hi.csdn.net/', linkh=0xFF00F0, font, font_hei ...

  7. imageView-scaleType 图片压缩属性

    今天用到了图片压缩的属性,自己参照网上的说明,验证了一下,截图如下 (1)当图片背景是方形的时候 代码如下 <LinearLayout android:id="@+id/l31&quo ...

  8. interpolator-动画执行方式

    动画中有一个属性是设置动画执行的方式, <?xml version="1.0" encoding="utf-8"?> <set xmlns:a ...

  9. Android中实现整个视图切换的左右滑动效果

    Android中提供了一个Gallary,可以实现图片或者文本的左右滑动效果. 如何让整个视图都能实现左右滑动,达到类似于Gallary的效果呢?可以直接用一个开源的ViewFlow来实现.   项目 ...

  10. ASP.NET路径解惑

    对于ASP.NET的路径问题,一直都是云里雾里,没有去详细的理解,今天正好可以梳理一下它们之间的关系和使用方法.而若想明白路径的表示方式的使用方法和区别以及注意事项可以通过下面的几个概念来进一步加深: ...