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

# Tailwind CSS Theme Adapter (React)

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="surveyCreatorContainer"></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/SurveyCreatorComponent.jsx`

```js
import React from "react";
import { SurveyCreator, SurveyCreatorComponent } from "survey-creator-react";
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";

function SurveyCreatorRenderComponent() {
    const creator = new SurveyCreator();
    configureCreatorSettings(creator, document.getElementById("tailwind-demo"));
    creator.JSON = surveyJSON;
    React.useEffect(() => creator.openCreatorThemeSettings(), [creator]);
    
    return (<SurveyCreatorComponent creator={creator} />);
}

export default SurveyCreatorRenderComponent;
```

### `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/index.js`

```js
import React from "react";
import { createRoot } from "react-dom/client";
import SurveyCreatorRenderComponent from "./SurveyCreatorComponent";

const root = createRoot(document.getElementById("surveyCreatorContainer"));
root.render(<SurveyCreatorRenderComponent />);
```

### `package.json`

```json
{
  "dependencies": {
    "react": "latest",
    "react-dom": "latest",
    "survey-core": "latest",
    "survey-react-ui": "latest",
    "survey-creator-core": "latest",
    "survey-creator-react": "latest"
  },
  "devDependencies": {
    "react-scripts": "latest"
  }
}
```

## Other Frameworks

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