Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
46 commits
Select commit Hold shift + click to select a range
4361635
renamed tailwind.mdx to tailwind-v3.mdx with updated links and instal…
deviate-dv8 Feb 8, 2025
2992963
updated tailwind docs to tailwind v4
deviate-dv8 Feb 8, 2025
94b1f1d
added tailwind-v3.mdx to data.json
deviate-dv8 Feb 8, 2025
d2bd68c
Merge branch 'main' into main
kodiakhq[bot] Feb 10, 2025
05f06d3
updated tailwind v4 docs usage from Vite Plugin to PostCSS plugin
deviate-dv8 Feb 10, 2025
2768f1d
Merge branch 'main' into main
kodiakhq[bot] Feb 13, 2025
6b3056a
Merge branch 'main' into main
kodiakhq[bot] Feb 13, 2025
4b487be
Merge branch 'main' into main
kodiakhq[bot] Feb 13, 2025
e6c2280
Merge branch 'main' into main
kodiakhq[bot] Feb 13, 2025
8694447
Merge branch 'main' into main
kodiakhq[bot] Feb 16, 2025
940b89a
Merge branch 'main' into main
kodiakhq[bot] Feb 16, 2025
0947d68
Merge branch 'main' into main
kodiakhq[bot] Feb 16, 2025
cce928d
Merge branch 'main' into main
kodiakhq[bot] Feb 18, 2025
91403a5
Merge branch 'main' into main
kodiakhq[bot] Feb 18, 2025
2936878
Merge branch 'main' into main
kodiakhq[bot] Feb 18, 2025
3541bb6
Merge branch 'main' into main
kodiakhq[bot] Feb 18, 2025
1ecf58b
Merge branch 'main' into main
kodiakhq[bot] Feb 18, 2025
011a8dc
Merge branch 'main' into main
kodiakhq[bot] Feb 18, 2025
6373542
Merge branch 'main' into main
kodiakhq[bot] Feb 18, 2025
861d06d
Merge branch 'main' into main
kodiakhq[bot] Feb 18, 2025
ffca020
Update src/routes/guides/styling-components/data.json removed tailwin…
deviate-dv8 Feb 20, 2025
9be9802
Update src/routes/guides/styling-components/tailwind.mdx
deviate-dv8 Feb 20, 2025
160cf54
Update src/routes/guides/styling-components/tailwind.mdx changed inst…
deviate-dv8 Feb 20, 2025
245ad7e
Update src/routes/guides/styling-components/tailwind.mdx
deviate-dv8 Feb 20, 2025
1b40566
Update src/routes/guides/styling-components/tailwind.mdx
deviate-dv8 Feb 20, 2025
8e9de13
Update src/routes/guides/styling-components/tailwind.mdx
deviate-dv8 Feb 20, 2025
e90aee5
Update src/routes/guides/styling-components/tailwind.mdx
deviate-dv8 Feb 20, 2025
5a2dc30
Update src/routes/guides/styling-components/tailwind.mdx updated tail…
deviate-dv8 Feb 20, 2025
5671940
Update src/routes/guides/styling-components/tailwind.mdx updated tail…
deviate-dv8 Feb 20, 2025
d325279
Update src/routes/guides/styling-components/tailwind.mdx
deviate-dv8 Feb 20, 2025
d47169e
Update src/routes/guides/styling-components/tailwind.mdx removed note…
deviate-dv8 Feb 20, 2025
7368b2e
Update src/routes/guides/styling-components/tailwind.mdx
deviate-dv8 Feb 20, 2025
4177c9c
Update src/routes/guides/styling-components/tailwind.mdx
deviate-dv8 Feb 20, 2025
901468d
Update src/routes/guides/styling-components/tailwind.mdx
deviate-dv8 Feb 20, 2025
906562f
Update src/routes/guides/styling-components/tailwind.mdx
deviate-dv8 Feb 20, 2025
976cd19
Update src/routes/guides/styling-components/tailwind.mdx
deviate-dv8 Feb 20, 2025
c2b5fc5
Update src/routes/guides/styling-components/tailwind.mdx
deviate-dv8 Feb 20, 2025
707380c
Update src/routes/guides/styling-components/tailwind.mdx
deviate-dv8 Feb 20, 2025
2bfe153
Update src/routes/guides/styling-components/tailwind.mdx
deviate-dv8 Feb 20, 2025
f3da123
Update src/routes/guides/styling-components/tailwind.mdx
deviate-dv8 Feb 20, 2025
a17daf1
Update src/routes/guides/styling-components/tailwind.mdx
deviate-dv8 Feb 20, 2025
e28e576
Update src/routes/guides/styling-components/tailwind.mdx
deviate-dv8 Feb 20, 2025
21caf9f
Update src/routes/guides/styling-components/tailwind.mdx
deviate-dv8 Feb 20, 2025
6f07cc1
Update src/routes/guides/styling-components/tailwind.mdx
deviate-dv8 Feb 20, 2025
4f459a8
Update src/routes/guides/styling-components/tailwind.mdx
deviate-dv8 Feb 20, 2025
9223996
Update tailwind.mdx
deviate-dv8 Feb 20, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
133 changes: 133 additions & 0 deletions src/routes/guides/styling-components/tailwind-v3.mdx
Original file line number Diff line number Diff line change
@@ -0,0 +1,133 @@
---
title: TailwindCSS v3
order: 7
mainNavExclude: true
---

[Tailwind CSS v3](https://v3.tailwindcss.com/) is an on-demand utility CSS library that integrates seamlessly with Solid as a built-in PostCSS plugin.

## Installation

1. Install Tailwind CSS as a development dependency:

<TabsCodeBlocks>
<div id="npm">
```bash frame="none"
npm i --save-dev tailwindcss@3 postcss autoprefixer
```
</div>

<div id="yarn">
```bash frame="none"
yarn add --dev tailwindcss@3 postcss autoprefixer
```
</div>

<div id="pnpm">
```bash frame="none"
pnpm add --save-dev tailwindcss@3 postcss autoprefixer
```
</div>

<div id="bun">
```bash frame="none"
bun add --save-dev tailwindcss@3 postcss autoprefixer
```
</div>
</TabsCodeBlocks>

2. Next, run the init command to generate both `tailwind.config.js` and `postcss.config.js`.

<TabsCodeBlocks>
<div id="npm">
```bash frame="none"
npx tailwindcss init -p
```
</div>

<div id="yarn">
```bash frame="none"
yarn dlx tailwindcss init -p
```
</div>

<div id="pnpm">
```bash frame="none"
pnpm dlx tailwindcss init -p
```
</div>

<div id="bun">
```bash frame="none"
bunx tailwindcss init -p
```
</div>
</TabsCodeBlocks>

3. Since TailwindCSS is configuration-driven, after initializing, a `tailwind.config.js` file will be created at the root of your project directory:

```js
/** @type {import('tailwindcss').Config} */
module.exports = {
content: ["./index.html", "./src/**/*.{js,ts,jsx,tsx}"],
theme: {
extend: {},
},
plugins: [],
};
```

For a deeper dive into configuration, you can check out the [Tailwind Official Documentation](https://tailwindcss.com/docs/configuration).

## Add Tailwind directives

In your `src/index.css` file, add the following Tailwind directives:

```css
@tailwind base;
@tailwind components;
@tailwind utilities;
```

These directives inform PostCSS that you're using Tailwind and establish the order of the directives. You can append custom CSS below these directives.

## Import TailwindCSS

Import your `index.css` file into the root `index.jsx` or `index.tsx` file:

```jsx
import { render } from "solid-js/web"
import App from "./App"
import "./index.css"

render(() => <App />, document.getElementById('root') as HTMLElement);
```

## Usage

With Tailwind CSS set up, you can now utilize its utility classes.
For instance, if you previously had a `Card.css` file, you can replace or remove it:

```
/* src/components/Card.css */
/* Remove or replace these styles with Tailwind utility classes */
```

Update your components to use Tailwind's utility classes:

```jsx
/* src/components/Card.jsx */
function Card() {
return (
<div class="grid place-items-center min-h-screen">
<div class="h-[160px] aspect aspect-[2] rounded-[16px] shadow-[0_0_0_4px_hsl(0_0%_0%_/_15%)]">
Hello, world!
</div>
</div>
);
}
```

## Support

For additional assistance, refer to the [Tailwind CSS/Vite integration guide](https://tailwindcss.com/docs/guides/vite).
79 changes: 28 additions & 51 deletions src/routes/guides/styling-components/tailwind.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -4,94 +4,71 @@ order: 5
mainNavExclude: true
---

[Tailwind CSS](https://tailwindcss.com/) is an on-demand utility CSS library that integrates seamlessly with Solid as a built-in PostCSS plugin.
<Callout type="info" title="Note">

This guide is for TailwindCSS v4. For **Tailwind CSS v3** refer to [TailwindCSS v3](/guides/styling-components/tailwind-v3).

</Callout>

[Tailwind CSS](https://tailwindcss.com/) is an on-demand utility CSS library that integrates seamlessly with Solid as a built-in PostCSS plugin.

## Installation

1. Install Tailwind CSS as a development dependency:

<TabsCodeBlocks>
<div id="npm">
```bash frame="none"
npm i --save-dev tailwindcss postcss autoprefixer
```
</div>

<div id="yarn">
```bash frame="none"
yarn add --dev tailwindcss postcss autoprefixer
npm i --save-dev tailwindcss @tailwindcss/postcss postcss
```
</div>

<div id="pnpm">
```bash frame="none"
pnpm add --save-dev tailwindcss postcss autoprefixer
```
</div>
<div id="yarn">

<div id="bun">
```bash frame="none"
bun add --save-dev tailwindcss postcss autoprefixer
yarn add --dev tailwindcss @tailwindcss/postcss postcss
```
</div>
</TabsCodeBlocks>

2. Next, run the init command to generate both `tailwind.config.js` and `postcss.config.js`.

<TabsCodeBlocks>
<div id="npm">
```bash frame="none"
npx tailwindcss init -p
```
</div>
<div id="pnpm">

<div id="yarn">
```bash frame="none"
yarn dlx tailwindcss init -p
pnpm add --save-dev tailwindcss @tailwindcss/postcss postcss
```
</div>

<div id="pnpm">
```bash frame="none"
pnpm dlx tailwindcss init -p
```
</div>

<div id="bun">

```bash frame="none"
bunx tailwindcss init -p
bun add --save-dev tailwindcss @tailwindcss/postcss postcss
```

</div>
</TabsCodeBlocks>

3. Since TailwindCSS is configuration-driven, after initializing, a `tailwind.config.js` file will be created at the root of your project directory:

```js
/** @type {import('tailwindcss').Config} */
module.exports = {
content: ["./index.html", "./src/**/*.{js,ts,jsx,tsx}"],
theme: {
extend: {},
},
plugins: [],
};
2. Add `@tailwind/postcss` to the `plugins` in your PostCSS configuration. If you do not have a PostCSS configuration file, create a new one called `postcss.config.mjs`.

```js title="postcss.config.mjs"
export default {
plugins: {
"@tailwindcss/postcss": {},
}
}
```

For a deeper dive into configuration, you can check out the [Tailwind Official Documentation](https://tailwindcss.com/docs/configuration).

## Add Tailwind directives
## Import TailwindCSS

In your `src/index.css` file, add the following Tailwind directives:
Add an `@import` to your `src/index.css` file that imports Tailwind CSS.

```css
@tailwind base;
@tailwind components;
@tailwind utilities;
```css title="src/index.css"
@import "tailwindcss";
```

These directives inform PostCSS that you're using Tailwind and establish the order of the directives. You can append custom CSS below these directives.

## Import TailwindCSS
## Import your CSS file

Import your `index.css` file into the root `index.jsx` or `index.tsx` file:

Expand Down