[Tailwind] Abstract Utility Classes to BEM Components in Tailwind
When creating UIs with utility classes, a lot of repetition can occur within the HTML markup. In this lesson, we see how this concern can be addressed by extracting a group of tailwind utility classes into a component classname. We create a Blocks Elements and Modifier (BEM) button component with a few style modifiers, that can be used everywhere in our project.
It is not reuseable when you only apply utilities class to the element.

The button way is:
<button class="button">Button</button>
So to create .button class and apply all the utilities class from tailwind, we can do:
.button {
@apply .font-bold .py-2 .px-4 .rounded;
}
.button-blue {
@apply .bg-blue .text-white;
}
.button-blue:hover {
@apply .bg-blue-dark;
}
Then we can use it like:
<button class="button button-blue">Button</button>
[Tailwind] Abstract Utility Classes to BEM Components in Tailwind的更多相关文章
- add a private constructor to hide the implicit public one(Utility classes should not have public constructors)
sonarlint提示add a private constructor to hide the implicit public one Utility classes should not have ...
- [Tailwind] Create Custom Utility Classes in Tailwind
In this lesson, we learn how to generate custom utility classes in tailwind. We add new properties t ...
- Top 15 Java Utility Classes
In Java, a utility class is a class that defines a set of methods that perform common functions. Thi ...
- Utility Classes Are Evil
原文地址:http://alphawang.com/blog/2014/09/utility-classes-are-evil/ This post is a summary of this arti ...
- [Tailwind] Extending Tailwind with Responsive Custom Utility Classes
You are able to extend the custom css with hover, focus, group-hover, responsive variants class in t ...
- [C++] OOP - Virtual Functions and Abstract Base Classes
Ordinarily, if we do not use a function, we do not need to supply a definition of the function. Howe ...
- python 用abc模块构建抽象基类Abstract Base Classes
见代码: #!/usr/bin/env python # -*- coding: utf-8 -*- # @Time : 2018/08/01 16:58 from abc import ABCMet ...
- [Tailwind] Style Elements on hover and focus with Tailwind’s State Variants
In this lesson, we learn how to target specific states of elements and apply styles only when those ...
- [Tailwind] Get started with Tailwindcss
In this lesson, we learn how to generate CSS utility classes from Tailwind's JavaScript config file. ...
随机推荐
- luogu2714 四元组统计 莫比乌斯反演 组合数
题目大意 给出一段序列,求其中最大公约数为1的四元组的个数. 思路 我们要用到反演.正难则反的思想.对于每一个大于1的数字\(x\),求出最大公约数为\(x\)的四元组的个数\(g(x)\),然后用排 ...
- h5-8 canvas
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/ ...
- 院校-美国:麻省理工学院(MIT)
ylbtech-院校-美国:麻省理工学院(MIT) 麻省理工学院(Massachusetts Institute of Technology),简称麻省理工(MIT),坐落于美国马萨诸塞州波士顿都市区 ...
- Super超级ERP系统---(10)订单打包
订单拣货完成后,需要把订单装箱打包,并打印客户地址信息.订单打包的操作流程先是扫描订单号,然后扫描商品条码. 1.订单打包 打印包装箱面单 2.订单发货 订单打包完成后就等待发货,快递公司来拉货的时 ...
- Navcat12 for mysq 激活工具
Navcat12 for mysq 激活 https://www.cnblogs.com/sunyangCoder/p/9060454.html
- BZOJ1211: [HNOI2004]树的计数(prufer序列)
Time Limit: 10 Sec Memory Limit: 162 MBSubmit: 2987 Solved: 1111[Submit][Status][Discuss] Descript ...
- 在windows系统下虚拟机和ubuntu系统的安装和卸载
一.安装 之前有装过双系统,但是吧,一直用ubuntu系统,很久没进windows之后的某一天,自己再进windows,发现windows系统崩了,我也不知道为什么,找了很多方法没有解决,最后只好重装 ...
- 第二课 TXT读取 - 导出 - 选择顶部/底部记录 - 描述性统计 - 分组/排序
第2课 创建数据 - 我们从创建自己的数据集开始分析.这可以防止阅读本教程的最终用户为得到下面的结果而不得不下载许多文件.我们将把这个数据集导出到一个文本文件中,这样您就可以获得从文本文件中一些拉取数 ...
- (转载) popupWindow 指定位置上的显示
popupWindow 指定位置上的显示 标签: androidpopupWindowpopupWindow具体位置放置 2014-07-09 16:23 1114人阅读 评论(0) 收藏 举报 分 ...
- ReactiveX
http://reactivex.io The real power comes with the “reactive extensions” (hence “ReactiveX”) — operat ...