astro/packages/integrations/tailwind
Nate Moore 17c02925c5
Migrate to new config (#2962)
* wip: config migration

* fix: formatting

* refactor: projectRoot -> root

* refactor: pageUrlFormat -> format

* refactor: buildOptions.site -> site

* refactor: public -> publicDir

* refactor: dist -> outDir

* refactor: styleOptions -> style

* fix: some dist tests -> outDir

* refactor: remove legacyBuild (with TODOs)

* refactor: more legacyBuild cleanup

* refactor: server host and port

* fix: remove experimentalStaticBuild CLI flag

* refactor: src -> srcDir

* refactor: devOptions.trailing -> trailing

* refactor: remove sitemap + related flags

* refactor: experimentalSSR -> experimental.ssr

* fix: last devOptions

* refactor: drafts -> markdown.drafts

* fix: TS error on port as const

* refactor: remove pages

* refactor: more --project-root updates

* refactor: markdownOptions -> markdown

* fix: remaining type errors

* feat: update AstroUserConfig

* refactor: update CLI flag mapper + server mapper

* fix: loadFixture projectRoot

* fix: merge CLI flags before validating / transforming

* wip: attempt to fix bad createRouteManifest config

* refactor: combine config.base and config.site

* fix: skip route manifest test for now

* fix: site and base handling

* refactor: update failing config testes

* fix: build failure

* feat: update config types with migration help

* chore: update types

* fix(deno): update deno fixture

* chore: remove config migration logic

* chore: remove logLevel

* chore: clean-up config types

* chore: update config warning

* chore: add changeset

* Sitemap Integration (#2965)

* feat: add sitemap filter config option

* feat: add canonicalURL sitemap config option

* docs: update sitemap README

* fix: update for new config

* fix: filter not being applied

* chore: changeset

Co-authored-by: bholmesdev <hey@bholmes.dev>

* fred pass

* fix: Astro.resolve typo

* fix: public => publicDir

Co-authored-by: bholmesdev <hey@bholmes.dev>
Co-authored-by: Fred K. Schott <fkschott@gmail.com>
2022-04-02 12:29:59 -06:00
..
src Migrate to new config (#2962) 2022-04-02 12:29:59 -06:00
base.css Astro Integration System (#2820) 2022-03-18 15:35:45 -07:00
CHANGELOG.md [ci] release (#2884) 2022-03-25 17:00:49 -05:00
package.json [ci] release (#2884) 2022-03-25 17:00:49 -05:00
README.md Allows projects to opt out of the base Tailwind styles (#2959) 2022-04-01 13:45:43 +00:00
tsconfig.json Astro Integration System (#2820) 2022-03-18 15:35:45 -07:00

@astrojs/tailwind 💨

This Astro integration brings Tailwind CSS to your Astro project.

Tailwind brings utility CSS classes for fonts, colors, layouts, transforms, and more to every Astro page or UI component in your project. It also includes extensive theming options for unifying your styles.

Installation

There are two ways to add integrations to your project. Let's try the most convenient option first!

(experimental) astro add command

Astro includes a CLI tool for adding first party integrations: astro add. This command will:

  1. (Optionally) Install all necessary dependencies and peer dependencies
  2. (Also optionally) Update your astro.config.* file to apply this integration

To install @astrojs/tailwind, run the following from your project directory and follow the prompts:

# Using NPM
npx astro add tailwind
# Using Yarn
yarn astro add tailwind
# Using PNPM
pnpx astro add tailwind

If you run into any hiccups, feel free to log an issue on our GitHub and try the manual installation steps below.

Install dependencies manually

First, install the @astrojs/tailwind integration like so:

npm install @astrojs/tailwind

Then, apply this integration to your astro.config.* file using the integrations property:

astro.config.mjs

import tailwind from '@astrojs/tailwind';

export default {
  // ...
  integrations: [tailwind()],
}

Getting started

Tailwind's utility classes should be ready-to-use with zero config, including preprocessor setup and production optimization. Head to the Tailwind docs to learn all of the options and features available!

Configuration

Have a custom theme? Try adding a tailwind.config.(js|cjs|mjs) file to the base of your project. You can also specify a custom config file using this integration's config.path option:

astro.config.mjs

import tailwind from '@astrojs/tailwind';

export default {
  // ...
  integrations: [tailwind({
    config: { path: './custom-config.js' },
  })],
}

We will provide a content property to your config to enable Tailwind across all Astro files and UI framework components. To remove this default, opt-out via the config.applyAstroPreset integration option:

astro.config.mjs

export default {
  // ...
  integrations: [tailwind({
    config: { applyAstroPreset: false },
  })],
}

We will include @tailwind directives for each of Tailwind's layers to enable Tailwind styles by default. If you need to customize this behavior, with Tailwind's @layer directive for example, opt-out via the config.applyBaseStyles integration option:

astro.config.mjs

export default {
  // ...
  integrations: [tailwind({
    config: { applyBaseStyles: false },
  })],
}

You can also check our Astro Integration Documentation for more on integrations.