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的更多相关文章

  1. [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 ...

  2. [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 ...

  3. [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 ...

  4. Utility Classes Are Evil

    原文地址:http://alphawang.com/blog/2014/09/utility-classes-are-evil/ This post is a summary of this arti ...

  5. How to: Create Custom Configuration Sections Using ConfigurationSection

    https://msdn.microsoft.com/en-us/library/2tw134k3.aspx You can extend ASP.NET configuration settings ...

  6. Top 15 Java Utility Classes

    In Java, a utility class is a class that defines a set of methods that perform common functions. Thi ...

  7. How to Create Custom Filters in AngularJs

    http://www.codeproject.com/Tips/829025/How-to-Create-Custom-Filters-in-AngularJs Introduction Filter ...

  8. create custom launcher icon 细节介绍

    create custom launcher icon 是创建你的Android app的图标 点击下一步的时候,出现的界面就是创建你的Android的图标 Foreground: ” Foregro ...

  9. 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 ...

随机推荐

  1. POJ2228 Naptime 环形DP

    题目大意:牛在第i个小时睡觉能够恢复U[i]点体力.睡觉时第一小时不恢复体力.一天的N小时连着下一天的1小时.求能够恢复体力的和的最大值. 定义DP[i][j][0]为前i个小时休息了j个小时,i小时 ...

  2. getLocationInWindow getLocationOnScreen getLeft , getTop, getBottom,getRight

    版权声明:本文为博主原创文章,未经博主允许不得转载. 最近做项目时,发现在activity的onCreate()和onResume()方法里调用View.getLocationInWindow() 时 ...

  3. Visio的安装教程

    1.下载地址:https://msdn.itellyou.cn/ 2.输入关键字:Visio,选择想要下载的版本,展开详细信息,并复制 3.(我下载的13) ed2k://|file|cn_visio ...

  4. Jungle Roads --hdoj

    Jungle Roads Time Limit : 2000/1000ms (Java/Other)   Memory Limit : 65536/32768K (Java/Other) Total ...

  5. MySQL-TokuDB:MySQL 高性能存储引擎:TokuDB

    ylbtech-MySQL-TokuDB:MySQL 高性能存储引擎:TokuDB 1.返回顶部 1. 在安装MariaDB的时候了解到代替InnoDB的TokuDB,看简介非常的棒,这里对ToduD ...

  6. mysql的递归(使用函数)

    getChildList: BEGIN #声明两个局部变量 ); ); #初始化局部变量 SET sTemp = ''; #调用cast函数将int转换为char SET sTempChd = roo ...

  7. 浅析CLR的GC(垃圾回收器)

    文章目录: 了解托管堆和GC GC高效的处理方式—代 特殊类型的清理 手动监控和控制对象生命周期 1.了解托管堆和GC 在面向对象环境中,每一个类型都代表了一种资源.我们要使用这些资源,就要为这些代表 ...

  8. MySQL定时任务与存储过程实例

    shell 定时任务:​/usr/bin/mysql -uroot -pxxxxx databasename -e "update table set ......."​​mysq ...

  9. TRS矩阵分解

    transform = TRS T就是transform的最后一列.关于R和S的分解,PBRT给了一个公式:M_(i+1) = (M_i + ((M_i)^T)^(-1))*0.5,直到M收敛.M初始 ...

  10. 将电脑特定文件夹保存在U盘中

    为什么 各种网盘,借着国家扫黄的阶梯,纷纷取消自己的网盘的服务.但自己有一些不是很大,但又很重要的东西,比如说代码(虽然学的渣) 怎么做 再网上百度,有一些将U盘的文件偷偷拷到电脑的脚本,改一下复制文 ...