|
1 | 1 | # Tailwind CSS |
2 | 2 |
|
3 | | -TODO... |
| 3 | +import LiveCodes from '../../src/components/LiveCodes.tsx'; |
| 4 | +import RunInLiveCodes from '../../src/components/RunInLiveCodes.tsx'; |
| 5 | + |
| 6 | +export const basicDemo = { |
| 7 | + activeEditor: 'markup', |
| 8 | + markup: { |
| 9 | + language: 'html', |
| 10 | + content: `<div class="flex items-center justify-center h-screen bg-gray-100">\n <h1 class="text-4xl font-bold text-blue-500">Hello, Tailwind!</h1>\n</div>\n`, |
| 11 | + }, |
| 12 | + processors: ['tailwindcss'], |
| 13 | +}; |
| 14 | + |
| 15 | +export const tailwindcssDemo = { |
| 16 | + activeEditor: 'script', |
| 17 | + script: { |
| 18 | + language: 'react', |
| 19 | + content: `export default function() {\n return <h1 className="text-3xl font-bold text-gray-500 text-center m-4">Hello, Tailwind CSS!</h1>;\n}\n`, |
| 20 | + }, |
| 21 | + processors: ['tailwindcss'], |
| 22 | +}; |
| 23 | + |
| 24 | +[Tailwind CSS](https://tailwindcss.com/) is an open-source CSS framework that provides utility CSS classes that can be composed to build any design, directly in the markup. |
| 25 | + |
| 26 | +## Demo |
| 27 | + |
| 28 | +<LiveCodes template="tailwindcss" height="60vh"></LiveCodes> |
| 29 | + |
| 30 | +## Usage |
| 31 | + |
| 32 | +Tailwind CSS is enabled as a [CSS processor](../features/css.mdx#css-processors). Once enabled from the style editor menu or in [`processors`](../configuration/configuration-object.mdx#processors) property of the [configuration object](../configuration/configuration-object.mdx), all Tailwind utility classes are available immediately in your markup. |
| 33 | + |
| 34 | +<RunInLiveCodes |
| 35 | + params={basicDemo} |
| 36 | + code={basicDemo.markup.content} |
| 37 | + language="html" |
| 38 | + formatCode={false} |
| 39 | +/> |
| 40 | + |
| 41 | +:::info note |
| 42 | + |
| 43 | +Tailwind CSS is imported using `@import "tailwindcss";` directive in the [style editor](../features/projects.mdx#style-editor). |
| 44 | + |
| 45 | +If no `@import` is added to the style editor, LiveCodes automatically injects it when the Tailwind CSS processor is enabled. |
| 46 | + |
| 47 | +::: |
| 48 | + |
| 49 | +### Usage with CSS Frameworks in JSX/SFCs |
| 50 | + |
| 51 | +CSS Frameworks supported in LiveCodes (e.g. Tailwind CSS, [UnoCSS](./unocss.mdx), [WindiCSS](./windicss.mdx)) can detect class names added in JSX and framework SFCs such as [React](./react.mdx), [Vue](./vue.mdx) and [Svelte](./svelte.mdx). Make sure that the Tailwind CSS processor is enabled. |
| 52 | + |
| 53 | +<RunInLiveCodes |
| 54 | + params={tailwindcssDemo} |
| 55 | + code={tailwindcssDemo.script.content} |
| 56 | + language="jsx" |
| 57 | +/> |
| 58 | + |
| 59 | +### Tailwind CSS Plugins |
| 60 | + |
| 61 | +Tailwind CSS plugins can be imported in the [style editor](../features/projects.mdx#style-editor). |
| 62 | + |
| 63 | +```css |
| 64 | +@import "@tailwindcss/forms"; |
| 65 | +@import "@tailwindcss/typography"; |
| 66 | +@import "@tailwindcss/aspect-ratio"; |
| 67 | +@import "@tailwindcss/line-clamp"; |
| 68 | +``` |
| 69 | + |
| 70 | + |
| 71 | +## Processor Info |
| 72 | + |
| 73 | +### Name |
| 74 | + |
| 75 | +`tailwindcss` |
| 76 | + |
| 77 | +## Compiler |
| 78 | + |
| 79 | +Tailwind CSS official compiler, running client-side in the browser. The compiler generates styles on-demand, so only the classes used in your markup are included in the output. |
| 80 | + |
| 81 | +### Version |
| 82 | + |
| 83 | +`tailwindcss`: v4.1.16 |
| 84 | + |
| 85 | +## Starter Template |
| 86 | + |
| 87 | +https://livecodes.io/?template=tailwindcss |
| 88 | + |
| 89 | +## Links |
| 90 | + |
| 91 | +- [Tailwind CSS](https://tailwindcss.com/) |
| 92 | +- [Tailwind CSS Documentation](https://tailwindcss.com/docs) |
| 93 | +- [LiveCodes CSS Processors](../features/css.mdx#css-processors) |
| 94 | +- [UnoCSS](./unocss.mdx) |
| 95 | +- [WindiCSS](./windicss.mdx) |
0 commit comments