---
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: Vue 3
source: https://surveyjs.io/survey-creator/examples/tailwind-theme-adapter/vue3js
index: https://surveyjs.io/survey-creator/examples/overview.md
---

# Tailwind CSS Theme Adapter (Vue 3)

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

### `public/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">
      <div id="app"></div>
    </div>
  </body>
</html>
```

### `src/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/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.vue`

```html
<template>
    <SurveyCreatorComponent :model="creator" />
</template>
<script setup lang="ts">
    import { SurveyCreatorModel } from "survey-creator-core";
    import { SurveyCreatorComponent } from "survey-creator-vue";
    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 "./index.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";
    
    const creator = new SurveyCreatorModel();
    configureCreatorSettings(creator, document.getElementById("tailwind-demo"));
    creator.JSON = surveyJSON;
    
    queueMicrotask(() => creator.openCreatorThemeSettings());
    
</script>
```

### `src/index.css`

```css
/* 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/main.ts`

```ts
import { createApp } from "vue";
import App from "./App.vue";

const app = createApp(App);
app.mount("#app");
```

### `src/shims-vue.d.ts`

```ts
/* eslint-disable */
declare module "*.vue" {
    import type { DefineComponent } from "vue"
    const component: DefineComponent<{}, {}, any>
    export default component
}
```

### `.babelrc`

```
{}
```

### `.eslintrc.js`

```js
module.exports = {
    root: true,
    env: {
        node: true
    },
    extends: [
        "plugin:vue/vue3-essential",
        "eslint:recommended",
        "@vue/typescript/recommended",
        "@vue/prettier",
        "@vue/prettier/@typescript-eslint"
    ],
    parserOptions: {
        ecmaVersion: 2020
    },
    rules: {
        "no-console": process.env.NODE_ENV === "production" ? "warn" : "off",
        "no-debugger": process.env.NODE_ENV === "production" ? "warn" : "off"
    },
    overrides: [
        {
            files: [
                "**/__tests__/*.{j,t}s?(x)",
                "**/tests/unit/**/*.spec.{j,t}s?(x)"
            ],
            env: {
                jest: true
            }
        }
    ]
};
```

### `babel.config.js`

```js
module.exports = {
  presets: ["@vue/cli-plugin-babel/preset"]
};
```

### `package.json`

```json
{
  "name": "surveyjs-library-vue3",
  "version": "0.1.0",
  "scripts": {
    "serve": "vue-cli-service serve",
    "build": "vue-cli-service build",
    "lint": "vue-cli-service lint"
  },
  "dependencies": {
    "core-js": "^3.6.5",
    "tslib": "2.6.1",
    "vue": "^3.4.1",
    "survey-core": "latest",
    "survey-vue3-ui": "latest",
    "survey-creator-core": "latest",
    "survey-creator-vue": "latest",
    "vue-router": "^4.0.0-0",
    "vuex": "^4.0.0-0"
  },
  "devDependencies": {
    "@typescript-eslint/eslint-plugin": "^2.33.0",
    "@typescript-eslint/parser": "^2.33.0",
    "@vue/cli-plugin-babel": "~4.5.0",
    "@vue/cli-plugin-eslint": "~4.5.0",
    "@vue/cli-plugin-pwa": "~4.5.0",
    "@vue/cli-plugin-router": "~4.5.0",
    "@vue/cli-plugin-typescript": "~4.5.0",
    "@vue/cli-plugin-vuex": "~4.5.0",
    "@vue/cli-service": "~4.5.0",
    "@vue/compiler-sfc": "^3.0.0",
    "@vue/eslint-config-prettier": "^6.0.0",
    "@vue/eslint-config-typescript": "^5.0.2",
    "@vue/test-utils": "^2.0.0-0",
    "eslint": "^6.7.2",
    "eslint-plugin-prettier": "^3.1.3",
    "eslint-plugin-vue": "^7.0.0-0",
    "node-sass": "^4.12.0",
    "prettier": "^1.19.1",
    "sass-loader": "^8.0.2",
    "typescript": "~3.9.3"
  }
}
```

### `tsconfig.json`

```json
{
  "compilerOptions": {
    "target": "esnext",
    "module": "esnext",
    "strict": true,
    "jsx": "preserve",
    "importHelpers": true,
    "moduleResolution": "node",
    "skipLibCheck": true,
    "esModuleInterop": true,
    "allowSyntheticDefaultImports": true,
    "sourceMap": true,
    "baseUrl": ".",
    "types": [
      "webpack-env",
      "jest"
    ],
    "paths": {
      "@/*": [
        "src/*"
      ]
    },
    "lib": [
      "esnext",
      "dom",
      "dom.iterable",
      "scripthost"
    ]
  },
  "include": [
    "src/**/*.ts",
    "src/**/*.tsx",
    "src/**/*.vue",
    "tests/**/*.ts",
    "tests/**/*.tsx"
  ],
  "exclude": [
    "node_modules"
  ]
}
```

## Other Frameworks

- [Angular](https://surveyjs.io/survey-creator/examples/tailwind-theme-adapter/angular.md)
- [React](https://surveyjs.io/survey-creator/examples/tailwind-theme-adapter/reactjs.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)
