Skip to content

Commit 81d0726

Browse files
committed
Update README
1 parent f87562c commit 81d0726

File tree

1 file changed

+67
-45
lines changed

1 file changed

+67
-45
lines changed

README.md

+67-45
Original file line numberDiff line numberDiff line change
@@ -14,27 +14,13 @@ A utility-first CSS framework for rapid UI development.
1414
yarn add git+ssh://git@github.com:nothingworksinc/tailwindcss.git#master
1515
```
1616

17-
2. Create a Tailwind config file for your project by copying the default config file from here:
17+
2. Create a Tailwind config file for your project by saving a copy of the default config file somewhere sensible, like `tailwind.js` in your project's root.
1818
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:
19+
You can copy the default config file from here:
2420
25-
```js
26-
const mix = require('laravel-mix');
27-
const tailwind = require('tailwindcss');
28-
29-
mix.less('resources/assets/less/app.less', 'public/css')
30-
.options({
31-
postCss: [
32-
tailwind(require('./path/to/your/tailwind/config.js'))
33-
]
34-
});
35-
```
21+
https://github.com/nothingworksinc/tailwindcss/blob/master/src/defaultConfig.js
3622
37-
4. Create a CSS (or Less, Sass, Stylus, whatever) file as your main stylesheet, structured like this:
23+
3. Create a CSS (or Less, Sass, Stylus, whatever) file as your main stylesheet, structured like this:
3824
3925
```less
4026
/**
@@ -68,6 +54,28 @@ A utility-first CSS framework for rapid UI development.
6854
}
6955
```
7056
57+
4. For simple projects or just taking Tailwind for a spin, use the `tailwind` CLI tool to process your CSS:
58+
59+
```sh
60+
./node_modules/.bin/tailwind styles.css [-c ./custom-config.js] [-o ./output.css]
61+
```
62+
63+
For most projects, you'll want to add Tailwind as a PostCSS plugin in your build chain, passing your config object as a parameter.
64+
65+
Here's an example using Laravel Mix:
66+
67+
```js
68+
const mix = require('laravel-mix');
69+
const tailwind = require('tailwindcss');
70+
71+
mix.less('resources/assets/less/app.less', 'public/css')
72+
.options({
73+
postCss: [
74+
tailwind(require('./path/to/your/tailwind/config.js'))
75+
]
76+
});
77+
```
78+
7179
## Style Reference
7280
7381
Until the real documentation is ready, you can reference this file to see which classes exist and what they do:
@@ -76,26 +84,40 @@ https://github.com/nothingworksinc/tailwindcss/blob/master/dist/tailwind.css
7684
7785
## Additional Features
7886
79-
### Classes as Mixins
87+
### Using utilities as mixins
8088
8189
To use existing utility classes as mixins in your custom component classes, use the `@apply` custom at-rule:
8290
8391
```less
92+
// Input
8493
.btn-primary {
85-
@apply .bg-blue;
86-
@apply .px-4;
87-
@apply .py-2;
88-
@apply .text-light;
94+
@apply .bg-blue;
95+
@apply .px-4;
96+
@apply .py-2;
97+
@apply .text-light;
98+
}
99+
.btn-primary:hover {
100+
@apply .bg-blue-dark;
101+
}
89102
90-
&:hover {
91-
@apply .bg-blue-dark;
92-
}
103+
// Output
104+
.btn-primary {
105+
background-color: #4aa2ea;
106+
padding-left: 1rem;
107+
padding-right: 1rem;
108+
padding-top: .5rem;
109+
padding-bottom: .5rem;
110+
color: #fff;
111+
}
112+
.btn-primary:hover {
113+
background-color: #3687c8;
93114
}
94115
```
95116
117+
96118
### Referencing config values in your CSS
97119
98-
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:
120+
It's not always possible to build components purely out of existing utilities. If you need to reference any of your Tailwind config values directly, you can do so with the `tailwind(...)` helper function:
99121

100122
```less
101123
.markdown pre {
@@ -110,37 +132,37 @@ You can generate responsive versions of your own utilities by wrapping their def
110132

111133
```css
112134
@responsive {
113-
.bg-gradient-brand {
114-
background-image: linear-gradient(blue, green);
115-
}
135+
.bg-gradient-brand {
136+
background-image: linear-gradient(blue, green);
137+
}
116138
}
117139
```
118140

119141
This will generate these classes (assuming you haven't changed the default breakpoints):
120142
121143
```css
122144
.bg-gradient-brand {
123-
background-image: linear-gradient(blue, green);
145+
background-image: linear-gradient(blue, green);
124146
}
125147
@media (min-width: 576px) {
126-
.sm\:bg-gradient-brand {
127-
background-image: linear-gradient(blue, green);
128-
}
148+
.sm\:bg-gradient-brand {
149+
background-image: linear-gradient(blue, green);
150+
}
129151
}
130152
@media (min-width: 768px) {
131-
.md\:bg-gradient-brand {
132-
background-image: linear-gradient(blue, green);
133-
}
153+
.md\:bg-gradient-brand {
154+
background-image: linear-gradient(blue, green);
155+
}
134156
}
135157
@media (min-width: 992px) {
136-
.lg\:bg-gradient-brand {
137-
background-image: linear-gradient(blue, green);
138-
}
158+
.lg\:bg-gradient-brand {
159+
background-image: linear-gradient(blue, green);
160+
}
139161
}
140162
@media (min-width: 1200px) {
141-
.xl\:bg-gradient-brand {
142-
background-image: linear-gradient(blue, green);
143-
}
163+
.xl\:bg-gradient-brand {
164+
background-image: linear-gradient(blue, green);
165+
}
144166
}
145167
```
146168
@@ -152,14 +174,14 @@ Instead of duplicating the values like this:
152174
153175
```css
154176
@media (min-width: 576px) {
155-
/* ... */
177+
/* ... */
156178
}
157179
```
158180
159181
...you can use the `@screen` at-rule and pass the breakpoint name:
160182
161183
```css
162184
@screen sm {
163-
/* ... */
185+
/* ... */
164186
}
165187
```

0 commit comments

Comments
 (0)