|
| 1 | +--- |
| 2 | +title: Tailwind Integration for {Platform} |
| 3 | +_description: Learn how to integrate Tailwind CSS with custom utility classes from the Ignite UI theming engine. This guide walks you through the setup and demonstrates how to use design tokens for colors, typography, and shadows in a utility-first approach. |
| 4 | +_keywords: {ProductName}, Infragistics, Themes, Styling, Tailwind CSS, custom CSS, utility classes, theming engine, typography, shadows, colors |
| 5 | +mentionedTypes: ["ConfigureTheme"] |
| 6 | +--- |
| 7 | + |
| 8 | +# Tailwind CSS Integration with Ignite UI for WebComponents |
| 9 | +Ignite UI for WebComponents offers full theming customization through CSS variables. In this guide, you'll learn how to integrate Tailwind CSS into your project and enhance it with custom utility classes provided by the `igniteui-theming` package. These classes expose Ignite UI design tokens for colors, shadows, and typography, enabling a seamless utility-first styling experience. |
| 10 | +<br> |
| 11 | + |
| 12 | +## Overview |
| 13 | + |
| 14 | +This guide assumes you already have **Ignite UI Theming** installed. If not, run: |
| 15 | + |
| 16 | +```cmd |
| 17 | +npm install igniteui-theming |
| 18 | +``` |
| 19 | + |
| 20 | +## Tailwind Setup |
| 21 | + |
| 22 | +Start by installing Tailwind CSS, according to your chosen build tool or framework by following the [official Tailwind installation guide](https://tailwindcss.com/docs/installation). |
| 23 | + |
| 24 | +Once Tailwind is set up, import both Tailwind and the Ignite UI theming configuration in your global stylesheet. |
| 25 | + |
| 26 | +```css |
| 27 | +@import 'tailwindcss'; |
| 28 | +@import 'igniteui-theming/tailwind/theme'; |
| 29 | +``` |
| 30 | + |
| 31 | +If your project uses `sass` for styling: |
| 32 | + |
| 33 | +```scss |
| 34 | +@import "tailwindcss"; |
| 35 | +@use "igniteui-theming/tailwind/theme"; |
| 36 | +``` |
| 37 | + |
| 38 | +## Using Ignite UI Custom Utility Classes |
| 39 | +The `igniteui-theming` package includes a custom Tailwind configuration that exposes Ignite UI design tokens through utility classes. These include support for: |
| 40 | + |
| 41 | +- Colors and contrast colors |
| 42 | + |
| 43 | +- Elevation (shadows) |
| 44 | + |
| 45 | +- Typography styles |
| 46 | + |
| 47 | +Let’s look at how to use each. |
| 48 | + |
| 49 | +### Color Utility Classes |
| 50 | +Our color utility classes are powered by tokens from each Ignite UI theme. You can apply them directly in your HTML: |
| 51 | + |
| 52 | +<!-- WebComponents --> |
| 53 | +```html |
| 54 | +<h1 class="bg-primary-500 text-primary-500-contrast">This is a title</h1> |
| 55 | +``` |
| 56 | +<!-- end: WebComponents --> |
| 57 | + |
| 58 | +You can explore Tailwind’s full color system [here](https://tailwindcss.com/docs/color), and apply it using the Ignite UI-provided class names. |
| 59 | +<br> |
| 60 | + |
| 61 | +### Shadow utility classes |
| 62 | + |
| 63 | +You can add depth using any of the predefined [elevation levels](https://www.infragistics.com/products/ignite-ui-web-components/web-components/components/themes/elevations) (from 0 to 24): |
| 64 | + |
| 65 | +<!-- WebComponents --> |
| 66 | +```html |
| 67 | +<div class="shadow-elevation-8">Elevated container</div> |
| 68 | +``` |
| 69 | +<!-- end: WebComponents --> |
| 70 | + |
| 71 | +You can find all the shadow-related utility classes provided by Tailwind [here](https://tailwindcss.com/docs/box-shadow) |
| 72 | +<br> |
| 73 | + |
| 74 | +### Typography custom utility styles |
| 75 | +To apply the font, add the `font-ig` class to a top-level element. You can also define the base font size using the `text-base` utility class. |
| 76 | +We provide custom utility classes for each typography level (e.g., h1, h2, body-1). Use them like so: |
| 77 | + |
| 78 | +<!-- WebComponents --> |
| 79 | +```html |
| 80 | +<p class="type-style-h3">This paragraph gets the h3 styles</p> |
| 81 | +``` |
| 82 | +<!-- end: WebComponents --> |
| 83 | + |
| 84 | +Each class applies all necessary font settings, spacing, and sizing according to the [Ignite UI type scale](https://www.infragistics.com/products/ignite-ui-web-components/web-components/components/themes/typography). |
| 85 | + |
| 86 | +## Sample |
| 87 | + |
| 88 | +In the sample below, you’ll see a 404 page built entirely with Tailwind utility classes, including our `custom utilities` for `shadows`, `colors`, and `typography`. |
| 89 | + |
| 90 | +`sample="/layouts/tailwind/styling", height="400", alt="{Platform} Tailwind Integration"` |
| 91 | + |
| 92 | +>[!NOTE] |
| 93 | +>This sample is fictional and fully custom, it’s not part of the Ignite UI component library. |
| 94 | +
|
| 95 | +## Summary |
| 96 | +With just a few configuration steps, you can combine Tailwind’s utility-first approach with Ignite UI’s robust design system. This integration allows you to rapidly build consistent, themed UI components using well-defined tokens for color, elevation, and typography, right from your HTML. |
0 commit comments