[Tailwind] Create Custom Utility Classes in Tailwind
In this lesson, we learn how to generate custom utility classes in tailwind. We add new properties to our JavaScript config object to generate new helper classes to suit our needs.
Update gulpfile.js:
const gulp = require("gulp");
const postcss = require("gulp-postcss");
const tailwindcss = require("tailwindcss");
const PATHS = {
css: "./src/styles.css",
config: "./tailwind.js",
dist: "./"
};
gulp.task("css", () => {
return gulp
.src(PATHS.css)
.pipe(postcss([tailwindcss(PATHS.config), require("autoprefixer")]))
.pipe(gulp.dest(PATHS.dist));
});
gulp.task("default", ["css"], () => {
gulp.watch(PATHS.config, ["css"]);
});
For example, you want to add some custom margin and padding in tailwind.js file:
margin: {
'auto': 'auto',
'px': '1px',
'0': '0',
'1': '0.25rem',
'2': '0.5rem',
'3': '0.75rem',
'4': '1rem',
'6': '1.5rem',
'8': '2rem',
'16': '4rem', //added
'crazy': '8rem', //added
},
padding: {
'px': '1px',
'0': '0',
'1': '0.25rem',
'2': '0.5rem',
'3': '0.75rem',
'4': '1rem',
'6': '1.5rem',
'8': '2rem',
'16': '4rem', //added
'crazy': '16rem', //added
},
After run 'gulp' command.
index.html
<h1 class="text-purple
bg-pink-dark
p-crazy mt-crazy">Hello Tailwind!</h1>
Checkout more on docs.
[Tailwind] Create Custom Utility Classes in Tailwind的更多相关文章
- [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 ...
- [Tailwind] Apply mobile-first Responsive Classes in Tailwind
In this lesson, we take a look at tailwind's mobile-first CSS architecture and learn how to apply st ...
- [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 thi ...
- Utility Classes Are Evil
原文地址:http://alphawang.com/blog/2014/09/utility-classes-are-evil/ This post is a summary of this arti ...
- How to: Create Custom Configuration Sections Using ConfigurationSection
https://msdn.microsoft.com/en-us/library/2tw134k3.aspx You can extend ASP.NET configuration settings ...
- Top 15 Java Utility Classes
In Java, a utility class is a class that defines a set of methods that perform common functions. Thi ...
- How to Create Custom Filters in AngularJs
http://www.codeproject.com/Tips/829025/How-to-Create-Custom-Filters-in-AngularJs Introduction Filter ...
- create custom launcher icon 细节介绍
create custom launcher icon 是创建你的Android app的图标 点击下一步的时候,出现的界面就是创建你的Android的图标 Foreground: ” Foregro ...
- 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 ...
随机推荐
- Working with macro signatures
https://docs.kentico.com/k11/macro-expressions/troubleshooting-macros/working-with-macro-signatures ...
- hdoj--1829--A Bug's Life(带权并查集)
A Bug's Life Time Limit: 15000/5000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others) To ...
- javaBean为什么要implements Serializable
转自:https://www.cnblogs.com/jqlbj/p/6261592.html 一个对象序列化的接口,一个类只有实现了Serializable接口,它的对象才是可序列化的.因此如果要序 ...
- day63-webservice 07.07.如何修改cxf配置文件路径
为什么第一次访问http://localhost:8080/cxf-web-server/service有点慢?证明第一次访问的时候CXFServlet被初始化了被加载了.一般是让CXFServlet ...
- js获取验证码 秒表效果(原创)
<script src="http://code.jquery.com/jquery-latest.js"></script> <input type ...
- MVP演化论
本文是翻译MVP: Model-View-Presenter The Taligent Programming Model for C++ and Java(Mike Potel)文章的摘要.该文介绍 ...
- javascript中天气接口案例
<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8&quo ...
- python os 模块常用操作
python 2.7 os 常用操作 官方document链接 文件和目录 os.access(path, mode) 读写权限测试 应用: try: fp = open("myfile&q ...
- [原创]Eclipse 安卓开发几个异常的处理办法
一.代码没有问题,就是报错,重启一下就会好.可以先clean再build; 二.R.Java丢失 网上讲了若干方法,有用android toos的,有clean再build的,我的解决办法是勾选bui ...
- CSS 弹性盒
图片新窗口打开浏览