---
title: Customize Surveys with CSS
product: Form Library
description: A free demo for JavaScript that shows how to easily customize your SurveyJS surveys or forms with custom CSS. Create a unique survey design that matches your brand's look and feel.
framework: jQuery
source: https://surveyjs.io/form-library/examples/customize-survey-with-css/jquery
index: https://surveyjs.io/form-library/examples/overview.md
---

# Customize Surveys with CSS (jQuery)

SurveyJS Form Library enables you to customize the appearance of your survey using CSS. Applied CSS classes are stored in a [JSON object](https://github.com/surveyjs/survey-library/blob/master/packages/survey-core/src/defaultCss/defaultCss.ts#L13). To override a CSS class, assign a substitute class to a corresponding JSON object property. In this demo, the `customCss` object is used to override CSS classes for question content, answered questions, and titles of required questions. Assign this object to `SurveyModel`'s [`css`](https://surveyjs.io/form-library/documentation/api-reference/survey-data-model#css) property.

You can also override styles dynamically based on a condition. Depending on the survey element whose classes you want to override, handle the following events:

- [`onUpdateQuestionCssClasses`](https://surveyjs.io/form-library/documentation/surveymodel#onUpdateQuestionCssClasses)
- [`onUpdatePanelCssClasses`](https://surveyjs.io/form-library/documentation/surveymodel#onUpdatePanelCssClasses)
- [`onUpdatePageCssClasses`](https://surveyjs.io/form-library/documentation/surveymodel#onUpdatePageCssClasses)
- [`onUpdateChoiceItemCss`](https://surveyjs.io/form-library/documentation/api-reference/survey-data-model#onUpdateChoiceItemCss)

The event handlers accept an object with useful properties as the second `options` parameter. Redefine individual properties in the `options.cssClasses` object to override required CSS classes. For example, this demo shows how to handle the `onUpdateQuestionCssClasses` event to override styles for Checkboxes questions only.

## Files

### `public/index.html`

```html
<div id="surveyElement" style="position: absolute; top: 0; left: 0; right: 0; bottom: 0; min-height: 100%; height:100%"></div>
```

### `src/index.css`

```css
.question-answered {
  background-color: rgba(25, 179, 148, 0.05);
}

.question-content .question-root {
  border: 1px solid lightgray;
  border-radius: 5px;
  border-left: 4px solid #18a689;
  padding: 20px;
  margin: 10px 0;
}

.question-content .question-root-checkboxes {
  border-left: 4px solid orange;
}

.question-title-required {
  color: #e60a3e;
}
```

### `src/index.js`

```js
import $ from "jquery";
import { Model } from "survey-core";
import "survey-js-ui";
import "survey-core/survey-core.min.css";
import "./index.css";
import { json } from "./json";

const customCss = {
    "question": {
        "content": "question-content",
        "answered": "question-answered",
        "titleRequired": "question-title-required"
    }
};
const survey = new Model(json);
survey.onComplete.add((sender, options) => {
    console.log(JSON.stringify(sender.data, null, 3));
});
survey.css = customCss;

survey.onUpdateQuestionCssClasses.add(function(_, options) {
    const classes = options.cssClasses;
    classes.root = "question-root";
    if (options.question.getType() === "checkbox") {
        classes.root += " question-root-checkboxes";
    }
});


$("#surveyElement").Survey({ model: survey });
```

### `src/json.js`

```js
export const json = {
  "elements": [
    {
      "type": "radiogroup",
      "name": "radio-button-group",
      "title": "Radio Button Group",
      "choices": [ "Yes", "No" ]
    },
    {
      "type": "checkbox",
      "name": "checkboxes",
      "title": "Checkboxes",
      "choices": [ "Item 1", "Item 2", "Item 3" ]
    },
    {
      "type": "radiogroup",
      "name": "required-radio-button-group",
      "title": "Required Question",
      "isRequired": true,
      "choices": [ "Yes", "No" ]
    }
  ]
};
```

### `src/theme.js`

```js
export const themeJson = {};
```

### `package.json`

```json
{
  "dependencies": {
    "jquery": "latest",
    "survey-core": "latest",
    "survey-js-ui": "latest"
  }
}
```

## Other Frameworks

- [Angular](https://surveyjs.io/form-library/examples/customize-survey-with-css/angular.md)
- [React](https://surveyjs.io/form-library/examples/customize-survey-with-css/reactjs.md)
- [Vue 3](https://surveyjs.io/form-library/examples/customize-survey-with-css/vue3js.md)
- [Vanilla JS](https://surveyjs.io/form-library/examples/customize-survey-with-css/vanillajs.md)
