Skip to content

Commit 55e3b60

Browse files
committed
Add quick and dirty README docs
1 parent 5616a99 commit 55e3b60

File tree

1 file changed

+161
-0
lines changed

1 file changed

+161
-0
lines changed

README.md

+161
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,164 @@
11
# TailwindCSS
22

33
A utility-first CSS framework for rapid UI development.
4+
5+
## Getting Started
6+
7+
1. Add the library to your project as a Git repo dependency:
8+
9+
```sh
10+
# Using npm
11+
npm install git+ssh://git@github.com:nothingworksinc/tailwindcss.git#master
12+
13+
# Using Yarn
14+
yarn add git+ssh://git@github.com:nothingworksinc/tailwindcss.git#master
15+
```
16+
17+
2. Create a Tailwind config file for your project by copying the default config file from here:
18+
19+
https://github.com/nothingworksinc/tailwindcss/blob/master/src/defaultConfig.js
20+
21+
3. Add Tailwind as a PostCSS plugin in your build chain, passing your config object as a parameter.
22+
23+
Here's an example using Laravel Mix:
24+
25+
```js
26+
const mix = require('laravel-mix');
27+
28+
mix..less('resources/assets/less/app.less', 'public/css')
29+
.options({
30+
postCss: [
31+
require('tailwindcss')(require('./tailwind.js'))
32+
]
33+
})
34+
```
35+
36+
4. Create a CSS (or Less, Sass, Stylus, whatever) file as your main stylesheet, structured like this:
37+
38+
```less
39+
/**
40+
* This injects Tailwind's base styles, which is a combination of
41+
* Normalize.css and some additional base styles.
42+
*
43+
* You can see the styles here:
44+
* https://github.com/nothingworksinc/tailwindcss/blob/master/css/preflight.css
45+
*/
46+
@tailwind reset;
47+
48+
/**
49+
* Here you would import any custom component classes; stuff that you'd
50+
* want loaded *before* the utilities so that the utilities can still
51+
* override them.
52+
*/
53+
@import "my-components/foo";
54+
@import "my-components/bar";
55+
56+
/**
57+
* This injects all of Tailwind's utility classes, generated based on your
58+
* config file.
59+
*/
60+
@tailwind utilities;
61+
62+
/**
63+
* Here you would add any custom utilities you need that don't come out of the box with Tailwind.
64+
*/
65+
.bg-hero-image {
66+
background-image: url('/some/image/file.png');
67+
}
68+
```
69+
70+
## Style Reference
71+
72+
Until the real documentation is ready, you can reference this file to see which classes exist and what they do:
73+
74+
https://github.com/nothingworksinc/tailwindcss/blob/master/dist/tailwind.css
75+
76+
## Additional Features
77+
78+
### Classes as Mixins
79+
80+
To use existing utility classes as mixins in your custom component classes, use the `@apply` custom at-rule:
81+
82+
```less
83+
.btn-primary {
84+
@apply .bg-blue;
85+
@apply .px-4;
86+
@apply .py-2;
87+
@apply .text-light;
88+
89+
&:hover {
90+
@apply .bg-blue-dark;
91+
}
92+
}
93+
```
94+
95+
### Referencing config values in your CSS
96+
97+
It's not always possible to build component purely out of existing utilities. If you need reference any of your Tailwind config values directly, you can do so with the `tailwind(...)` helper function:
98+
99+
```less
100+
.markdown pre {
101+
border: 1px solid tailwind('borders.defaults.color');
102+
border-left: 4px solid tailwind('borders.colors.dark');
103+
}
104+
```
105+
106+
### Creating responsive versions of your own utilities
107+
108+
You can generate responsive versions of your own utilities by wrapping their definitions in the `@responsive` at-rule:
109+
110+
```css
111+
@responsive {
112+
.bg-gradient-brand {
113+
background-image: linear-gradient(blue, green);
114+
}
115+
}
116+
```
117+
118+
This will generate these classes (assuming you haven't changed the default breakpoints):
119+
120+
```css
121+
.bg-gradient-brand {
122+
background-image: linear-gradient(blue, green);
123+
}
124+
@media (min-width: 576px) {
125+
.sm\:bg-gradient-brand {
126+
background-image: linear-gradient(blue, green);
127+
}
128+
}
129+
@media (min-width: 768px) {
130+
.md\:bg-gradient-brand {
131+
background-image: linear-gradient(blue, green);
132+
}
133+
}
134+
@media (min-width: 992px) {
135+
.lg\:bg-gradient-brand {
136+
background-image: linear-gradient(blue, green);
137+
}
138+
}
139+
@media (min-width: 1200px) {
140+
.xl\:bg-gradient-brand {
141+
background-image: linear-gradient(blue, green);
142+
}
143+
}
144+
```
145+
146+
### Media query shorthand
147+
148+
Say you have a `sm` breakpoint at 576px, and you need to write some custom CSS that references this breakpoint.
149+
150+
Instead of duplicating the values like this:
151+
152+
```css
153+
@media (min-width: 576px) {
154+
/* ... */
155+
}
156+
```
157+
158+
...you can use the `@screen` at-rule and pass the breakpoint name:
159+
160+
```css
161+
@screen sm {
162+
/* ... */
163+
}
164+
```

0 commit comments

Comments
 (0)