首页 > 代码库 > [TypeStyle] Add type safety to CSS using TypeStyle
[TypeStyle] Add type safety to CSS using TypeStyle
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
声明:以上内容来自用户投稿及互联网公开渠道收集整理发布,本网站不拥有所有权,未作人工编辑处理,也不承担相关法律责任,若内容有误或涉及侵权可进行投诉: 投诉/举报 工作人员会在5个工作日内联系你,一经查实,本站将立刻删除涉嫌侵权内容。