---
title: Tailwind CSS Theme Adapter
product: Survey Creator
description: Style Survey Creator with the Tailwind CSS theme adapter. Use Creator Settings to change the primary color, light or dark mode, and corner radius.
framework: Angular
source: https://surveyjs.io/survey-creator/examples/tailwind-theme-adapter/angular
index: https://surveyjs.io/survey-creator/examples/overview.md
---

# Tailwind CSS Theme Adapter (Angular)

This demo styles Survey Creator with the Tailwind CSS v4 theme adapter. Use **Tailwind Settings** to change the primary color, light/dark appearance, and corner radius. The builder and the form being designed update together.

[Tailwind CSS v4 Theme Adapter Documentation](/form-library/documentation/theme-adapters#tailwind-css-v4 (linkStyle))

## Files

### `src/app/components/creator.component.css`

```css
:host {
  display: block;
  height: 100%;
}
```

### `src/app/components/creator.component.html`

```html
<survey-creator [model]="model"></survey-creator>
```

### `src/app/components/survey-json.js`

```js
export const surveyJSON = {
  "title": "Contact preferences",
  "description": "Keep your profile and updates in sync.",
  "widthMode": "responsive",
  "completeText": "Save preferences",
  "pages": [
    {
      "name": "preferences",
      "elements": [
        {
          "type": "text",
          "name": "fullName",
          "title": "Full name",
          "isRequired": true,
          "autocomplete": "name",
          "placeholder": "Alex Morgan"
        },
        {
          "type": "text",
          "name": "email",
          "title": "Email address",
          "isRequired": true,
          "inputType": "email",
          "autocomplete": "email",
          "placeholder": "alex@example.com"
        },
        {
          "type": "dropdown",
          "name": "role",
          "title": "Your role",
          "placeholder": "Select your role",
          "choices": [
            { "value": "designer", "text": "Designer" },
            { "value": "developer", "text": "Developer" },
            { "value": "productManager", "text": "Product manager" }
          ]
        },
        {
          "type": "radiogroup",
          "name": "contactMethod",
          "title": "Preferred contact method",
          "defaultValue": "email",
          "choices": [
            { "value": "email", "text": "Email" },
            { "value": "phone", "text": "Phone" }
          ]
        },
        {
          "type": "checkbox",
          "name": "updates",
          "title": "Send me updates about",
          "choices": [
            { "value": "productNews", "text": "Product news" },
            { "value": "tutorials", "text": "Tips and tutorials" }
          ]
        },
        {
          "type": "comment",
          "name": "notes",
          "title": "Notes",
          "rows": 3,
          "placeholder": "Anything else we should know?"
        }
      ]
    }
  ]
};
```

### `src/app/components/tailwind-demo.js`

```js
export function configureCreatorSettings(creator, demo) {
    const values = {
        primary: "indigo",
        mode: "light",
        radius: "rounded"
    };
    const colors = {
        indigo: "#4f46e5",
        blue: "#2563eb",
        emerald: "#047857",
        rose: "#be123c"
    };

    function applyTailwindSettings() {
        if (!demo) return;
        demo.style.setProperty("--color-primary", colors[values.primary]);
        demo.style.setProperty("--color-ring", colors[values.primary]);
        demo.dataset.mode = values.mode;
        demo.dataset.radius = values.radius;
    }

    creator.onSurveyInstanceCreated.add((_, { area, survey }) => {
        if (area !== "designer-tab:creator-settings:theme") return;
        survey.fromJSON({
            showNavigationButtons: false,
            elements: [{
                type: "dropdown",
                name: "primary",
                title: "Primary color",
                allowClear: false,
                searchEnabled: false,
                choices: [
                    { value: "indigo", text: "Indigo" },
                    { value: "blue", text: "Blue" },
                    { value: "emerald", text: "Emerald" },
                    { value: "rose", text: "Rose" }
                ]
            }, {
                type: "dropdown",
                name: "mode",
                title: "Appearance",
                allowClear: false,
                searchEnabled: false,
                choices: [
                    { value: "light", text: "Light" },
                    { value: "dark", text: "Dark" }
                ]
            }, {
                type: "dropdown",
                name: "radius",
                title: "Corner radius",
                allowClear: false,
                searchEnabled: false,
                choices: [
                    { value: "square", text: "Square" },
                    { value: "rounded", text: "Rounded" },
                    { value: "soft", text: "Soft" }
                ]
            }]
        });
        survey.onValueChanged.add((_, options) => {
            if (!Object.hasOwn(values, options.name)) return;
            values[options.name] = options.value;
            applyTailwindSettings();
        });
        survey.onAfterRenderSurvey.add(() => {
            survey.data = values;
        });
    });

    applyTailwindSettings();
}
```

### `src/app/components/creator.component.ts`

```ts
import { Component, OnInit } from "@angular/core";
import { SurveyCreatorModel } from "survey-creator-core";
import "survey-core/survey.i18n";
import "survey-creator-core/survey-creator-core.i18n";
import "survey-core/survey-core.css";
import "survey-creator-core/survey-creator-core.css";

import SurveyTheme from "survey-core/themes";
import { registerCreatorTheme } from "survey-creator-core";

registerCreatorTheme(SurveyTheme); // Add predefined Survey Creator UI themes

import "survey-core/themes/adapters/tailwind4.css";
import { getLocaleStrings } from "survey-creator-core";
import { surveyJSON } from "./survey-json";
import { configureCreatorSettings } from "./tailwind-demo";

getLocaleStrings("en").ed.creatorSettingTitle = "Tailwind Settings";

@Component({
    // tslint:disable-next-line:component-selector
    selector: "component-survey-creator",
    templateUrl: "./creator.component.html",
    styleUrls: ["./creator.component.css"]
})
export class SurveyCreatorComponent implements OnInit {
    model: SurveyCreatorModel;
    ngOnInit() {
        const creator = new SurveyCreatorModel();
        configureCreatorSettings(creator, document.getElementById("tailwind-demo"));
        creator.JSON = surveyJSON;
        
        queueMicrotask(() => creator.openCreatorThemeSettings());
        
        this.model = creator;
    }
}
```

### `src/app/app.component.html`

```html
<component-survey-creator></component-survey-creator>
```

### `src/app/app.component.ts`

```ts
import { Component } from "@angular/core";

@Component({
    selector: "app-root",
    templateUrl: "./app.component.html"
})
export class AppComponent {
    title = "CodeSandbox";
}
```

### `src/app/app.module.ts`

```ts
import { BrowserModule } from "@angular/platform-browser";
import { NgModule } from "@angular/core";
import { AppComponent } from "./app.component";
import { SurveyCreatorModule } from "survey-creator-angular";
import { SurveyCreatorComponent } from "./components/creator.component";

@NgModule({
    declarations: [AppComponent, SurveyCreatorComponent],
    imports: [BrowserModule, SurveyCreatorModule],
    providers: [],
    bootstrap: [AppComponent]
})
export class AppModule { }
```

### `src/environments/environment.prod.ts`

```ts
export const environment = {
    production: true
};
```

### `src/environments/environment.ts`

```ts
// The file contents for the current environment will overwrite these during build.
// The build system defaults to the dev environment which uses `environment.ts`, but if you do
// `ng build --env=prod` then `environment.prod.ts` will be used instead.
// The list of which env maps to which file can be found in `.angular-cli.json`.

export const environment = {
    production: false
};
```

### `src/index.html`

```html
<link href="https://fonts.googleapis.com/css?family=Open%20Sans:400,600&display=swap" rel="stylesheet">
<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="utf-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1" />
    <title>Tailwind CSS Theme Adapter for Survey Creator</title>
  </head>
  <body>
    <div id="tailwind-demo" class="tailwind-demo" data-mode="light" data-radius="rounded">
      <app-root></app-root>
    </div>
  </body>
</html>
```

### `src/main.ts`

```ts
import { enableProdMode } from "@angular/core";
import { platformBrowserDynamic } from "@angular/platform-browser-dynamic";

import { AppModule } from "./app/app.module";
import { environment } from "./environments/environment";

if (environment.production) {
    enableProdMode();
}

platformBrowserDynamic()
    .bootstrapModule(AppModule)
    .catch(err => console.log(err));
```

### `src/polyfills.ts`

```ts
/**
 * This file includes polyfills needed by Angular and is loaded before the app.
 * You can add your own extra polyfills to this file.
 *
 * This file is divided into 2 sections:
 *   1. Browser polyfills. These are applied before loading ZoneJS and are sorted by browsers.
 *   2. Application imports. Files imported after ZoneJS that should be loaded before your main
 *      file.
 *
 * The current setup is for so-called "evergreen" browsers; the last versions of browsers that
 * automatically update themselves. This includes Safari >= 10, Chrome >= 55 (including Opera),
 * Edge >= 13 on the desktop, and iOS 10 and Chrome on mobile.
 *
 * Learn more in https://angular.io/docs/ts/latest/guide/browser-support.html
 */

/***************************************************************************************************
 * BROWSER POLYFILLS
 */

/** IE9, IE10 and IE11 requires all of the following polyfills. **/
// import 'core-js/es6/symbol';
// import 'core-js/es6/object';
// import 'core-js/es6/function';
// import 'core-js/es6/parse-int';
// import 'core-js/es6/parse-float';
// import 'core-js/es6/number';
// import 'core-js/es6/math';
// import 'core-js/es6/string';
// import 'core-js/es6/date';
// import 'core-js/es6/array';
// import 'core-js/es6/regexp';
// import 'core-js/es6/map';
// import 'core-js/es6/weak-map';
// import 'core-js/es6/set';

/** IE10 and IE11 requires the following for NgClass support on SVG elements */
// import 'classlist.js';  // Run `npm install classlist.js`.

/** IE10 and IE11 requires the following for the Reflect API. */
// import 'core-js/es6/reflect';

/** Evergreen browsers require these. **/
// Used for reflect-metadata in JIT. If you use AOT (and only Angular decorators), you can remove.
import "core-js/proposals/reflect-metadata";

/**
 * Required to support Web Animations `@angular/platform-browser/animations`.
 * Needed for: All but Chrome, Firefox and Opera. http://caniuse.com/#feat=web-animation
 **/
// import 'web-animations-js';  // Run `npm install web-animations-js`.

/***************************************************************************************************
 * Zone JS is required by default for Angular itself.
 */
import "zone.js/dist/zone"; // Included with Angular CLI.

/***************************************************************************************************
 * APPLICATION IMPORTS
 */
```

### `src/styles.css`

```css
/* You can add global styles to this file and import other style files */
/* Host theme tokens shared by Creator Settings and the Tailwind theme adapter. */
.tailwind-demo {
  --spacing: 0.25rem;
  --font-sans: ui-sans-serif, system-ui, sans-serif;
  --text-xs: 0.75rem;
  --text-sm: 0.875rem;
  --text-base: 1rem;
  --color-primary: #4f46e5;
  --color-primary-foreground: #ffffff;
  --color-primary-hover: color-mix(in srgb, var(--color-primary) 85%, black);
  --color-ring: var(--color-primary);
  --color-background: #f9fafb;
  --color-card: #ffffff;
  --color-foreground: #111827;
  --color-muted-foreground: #6b7280;
  --color-input: #d1d5db;
  --color-border: #e5e7eb;
  --color-destructive: #dc2626;
  --radius-sm: 0.25rem;
  --radius-md: 0.375rem;
  --radius-lg: 0.5rem;
  box-sizing: border-box;
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  min-width: 0;
  min-height: 0;
  background: var(--color-background);
  color: var(--color-foreground);
  color-scheme: light;
  font-family: var(--font-sans);
  font-size: var(--text-sm);
  line-height: 1.25rem;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  overflow: hidden;
}

.tailwind-demo[data-mode="dark"] {
  --color-background: #030712;
  --color-card: #111827;
  --color-foreground: #f9fafb;
  --color-muted-foreground: #9ca3af;
  --color-input: #4b5563;
  --color-border: #374151;
  --color-destructive: #f87171;
  color-scheme: dark;
}

.tailwind-demo[data-radius="square"] {
  --radius-sm: 0px;
  --radius-md: 0px;
  --radius-lg: 0px;
}

.tailwind-demo[data-radius="soft"] {
  --radius-sm: 0.375rem;
  --radius-md: 0.75rem;
  --radius-lg: 1rem;
}

.tailwind-demo *,
.tailwind-demo *::before,
.tailwind-demo *::after {
  box-sizing: border-box;
}

.tailwind-demo > *,
.tailwind-demo component-survey-creator,
.tailwind-demo survey-creator,
.tailwind-demo .svc-creator {
  height: 100%;
  min-width: 0;
  min-height: 0;
}

.tailwind-demo app-root,
.tailwind-demo component-survey-creator {
  display: block;
  min-width: 0;
}

/* Creator uses the same design tokens as the Form Library adapter. */
.tailwind-demo .sjs-theme-overrides {
  --sjs2-base-unit-radius: var(--radius-md);
  --sjs2-radius-component-page: var(--radius-lg);
  --sjs2-radius-component-modal: var(--radius-lg);
  --sjs2-color-utility-body: var(--color-card);
  --sjs2-color-utility-toolbox: var(--color-card);
  --sjs2-color-utility-property-grid: var(--color-card);
  --sjs2-color-utility-tabs: var(--color-card);
  --sjs2-color-utility-surface-designer: var(--color-background);
  --sjs2-color-utility-surface-json-editor: var(--color-card);
  --sjs2-color-bg-basic-primary-dim: color-mix(in srgb, var(--color-card) 90%, var(--color-foreground));
  --sjs2-color-bg-basic-secondary-dim: color-mix(in srgb, var(--color-card) 85%, var(--color-foreground));
  --sjs2-color-bg-basic-primary-disabled: var(--color-background);
  --sjs2-color-bg-neutral-secondary: var(--color-background);
  --sjs2-color-bg-neutral-secondary-dim: color-mix(in srgb, var(--color-card) 85%, var(--color-foreground));
  --sjs2-color-component-formbox-design-bg: var(--color-background);
  --ctr-code-viewer-text-color: var(--color-foreground);
}
```

### `src/typings.d.ts`

```ts
/* SystemJS module definition */
declare var module: NodeModule;
interface NodeModule {
    id: string;
}
```

### `.angular-cli.json`

```json
{
  "apps": [
    {
      "root": "src",
      "outDir": "dist",
      "assets": [ "assets", "favicon.ico" ],
      "index": "index.html",
      "main": "main.ts",
      "polyfills": "polyfills.ts",
      "prefix": "app",
      "styles": [ "styles.css"  ],
      "scripts": [  ],
      "environmentSource": "environments/environment.ts",
      "environments": {
        "dev": "environments/environment.ts",
        "prod": "environments/environment.prod.ts"
      }
    }
  ]
}
```

### `_tsconfig.json`

```json
{
  "compileOnSave": false,
  "compilerOptions": {
    "baseUrl": "./",
    "outDir": "./dist/out-tsc",
    "sourceMap": true,
    "declaration": false,
    "allowSyntheticDefaultImports": true,
    "downlevelIteration": true,
    "experimentalDecorators": true,
    "moduleResolution": "node",
    "importHelpers": true,
    "resolveJsonModule": true,
    "target": "es2015",
    "module": "es2020",
    "lib": [
      "es2018",
      "dom"
    ]
  }
}
```

### `package.json`

```json
{
  "name": "surveyjs-angular",
  "scripts": {
    "ng": "ng",
    "start": "ng serve",
    "build": "ng build --prod",
    "test": "ng test",
    "lint": "ng lint",
    "e2e": "ng e2e"
  },
  "private": true,
  "dependencies": {
    "@angular/animations": "14.1.1",
    "@angular/cdk": "14.1.1",
    "@angular/common": "14.1.1",
    "@angular/compiler": "14.1.1",
    "@angular/core": "14.1.1",
    "@angular/forms": "14.1.1",
    "@angular/platform-browser": "14.1.1",
    "@angular/platform-browser-dynamic": "14.1.1",
    "@angular/router": "14.1.1",
    "core-js": "3.6.4",
    "rxjs": "6.5.4",
    "survey-angular-ui": "latest",
    "survey-creator-core": "latest",
    "survey-core": "latest",
    "survey-creator-angular": "latest",
    "tslib": "1.13.0",
    "zone.js": "0.11.7"
  },
  "devDependencies": {
    "@angular-devkit/build-angular": "~13.0.0",
    "@angular/cli": "~13.0.0",
    "@types/jasmine": "3.6.3",
    "@types/jasminewd2": "2.0.8",
    "@types/node": "14.14.28",
    "codelyzer": "6.0.1",
    "jasmine-core": "3.6.0",
    "jasmine-spec-reporter": "6.0.0",
    "karma": "6.1.1",
    "karma-chrome-launcher": "3.1.0",
    "karma-coverage-istanbul-reporter": "3.0.3",
    "karma-jasmine": "4.0.1",
    "karma-jasmine-html-reporter": "1.5.4",
    "protractor": "7.0.0",
    "ts-node": "9.1.1",
    "tslint": "~6.1.3",
    "typescript": "4.1.5"
  },
  "keywords": [ "angular", "surveyjs" ],
  "description": "SurveyJS-Angular example project"
}
```

## Other Frameworks

- [React](https://surveyjs.io/survey-creator/examples/tailwind-theme-adapter/reactjs.md)
- [Vue 3](https://surveyjs.io/survey-creator/examples/tailwind-theme-adapter/vue3js.md)
- [jQuery](https://surveyjs.io/survey-creator/examples/tailwind-theme-adapter/jquery.md)
- [Vanilla JS](https://surveyjs.io/survey-creator/examples/tailwind-theme-adapter/vanillajs.md)
