Skip to content

Commit

Permalink
docs: add some tailwind docs
Browse files Browse the repository at this point in the history
  • Loading branch information
jquense committed Mar 23, 2022
1 parent bfbd195 commit a996bc5
Show file tree
Hide file tree
Showing 2 changed files with 79 additions and 0 deletions.
62 changes: 62 additions & 0 deletions packages/tailwind/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
# react-widgets-tailwind

A TailwindCSS plugin for react-widgets as an alternative to Sass

## Usage

```
npm i react-widgets-tailwind --save-dev
```

In your `tailwind.config.js` file:

```js
const ppath = require('path')

module.exports = {
content: [
// point the JIT to the fully compiled css file to ensure all classes are included
require.resolve('react-widgets/styles.css'),
],

/* ... */
plugins: [require('react-widgets-tailwind')],
}
```

The additional config of `content` is required for tailwind v3 in order to inform tailwind what classes are
actually in use.

### Controling which components you include

Relying on the Tailwind JIT to only include used styles doesn't work for react component libraries. This
is because the JIT only looks at source files, not which components you've actually used in your app.

To limit which component styles are included you can customize the plugin with the components you want:

```js
const ppath = require('path')

module.exports = {
content: [
// point the JIT to the fully compiled css file to ensure all classes are included
require.resolve('react-widgets/styles.css'),
],

/* ... */
plugins: [
require('react-widgets-tailwind')({
components: [
'Listbox',
'DropdownList',
'Combobox',
'Multiselect',
'DatePicker',
'Calendar',
'TimeInput',
'NumberPicker',
],
}),
],
}
```
17 changes: 17 additions & 0 deletions www/docs/getting-started.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ and don't require additional configuration.
values={[
{ label: 'CSS', value: 'css' },
{ label: 'Sass', value: 'scss', },
{ label: 'TailwindCSS', value: 'talwind', },
]
}>
<TabItem value="css">
Expand All @@ -57,6 +58,22 @@ import "react-widgets/styles.css";
import "react-widgets/scss/styles.scss";
```

</TabItem>
<TabItem value="talwind">

```js
// in your tailwind.config.js
{
content: [
// point the JIT to the fully compiled css file
// to ensure all classes are included
require.resolve('react-widgets/styles.css'),
],

plugins: [require('react-widgets-tailwind')];
}
```

</TabItem>
</Tabs>

Expand Down

0 comments on commit a996bc5

Please sign in to comment.