---
title: Configure Slider Scale Labels
product: Form Library
description: Learn how to configure and customize scale labels on SurveyJS Single-Value Slider and Range Slider questions. This demo covers auto-generated labels, custom label definitions, and label formatting options. Create clear, user-friendly sliders with meaningful visual reference points or hide labels entirely if needed.
framework: React
source: https://surveyjs.io/form-library/examples/customize-slider-scale-labels/reactjs
index: https://surveyjs.io/form-library/examples/overview.md
---

# Configure Slider Scale Labels (React)

Labels divide the slider scale into visual reference points and give users a clear idea of the available range. Users can click a label to select the corresponding value. Both the SurveyJS Single-Value Slider and Range Slider inputs support auto-generated and custom scale labels. This demo shows how to configure either type, format the labels, or hide them entirely.

## Auto-Generated Scale Labels

To generate labels automatically, specify their number using the [`labelCount`](/form-library/documentation/api-reference/questionslidermodel#labelCount) property. By default, six labels are displayed. In this demo, the number is increased to 11. Each label is positioned at the value it represents.

## Custom Scale Labels

If the auto-generated labels don't meet your needs, you can define custom ones using the [`customLabels`](/form-library/documentation/api-reference/questionslidermodel#customLabels) array. Each item in this array should be a number&mdash;the scale value where the label should appear&mdash;or an object with the following fields:

- `value`: `number`         
The scale value where the label should appear.

- `text`: `string`          
The label text to display.

When defined, custom labels override auto-generated ones. This example demonstrates how to use `customLabels` to display descriptive text instead of numeric values.

## Label Formatting

To apply a specific format to scale labels, use the [`labelFormat`](/form-library/documentation/api-reference/questionslidermodel#labelFormat) property. Include the `{0}` placeholder in your format string to insert the label value&mdash;for example, to prefix labels with a dollar sign. You can use the same formatting approach for thumb tooltips using the [`tooltipFormat`](/form-library/documentation/api-reference/questionslidermodel#tooltipFormat) property.

> If you are using custom labels, `labelFormat` affects only those that do not define the `text` property.

If you want to hide all scale labels, set the [`showLabels`](/form-library/documentation/api-reference/questionslidermodel#showLabels) property to `false`.

## 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/SurveyComponent.jsx`

```js
import React from "react";
import { Model } from "survey-core";
import { Survey } from "survey-react-ui";
import "survey-core/survey-core.min.css";
import "./index.css";
import { json } from "./json";

function SurveyComponent() {
    const survey = new Model(json);
    survey.onComplete.add((sender, options) => {
        console.log(JSON.stringify(sender.data, null, 3));
    });
    return (<Survey model={survey} />);
}

export default SurveyComponent;
```

### `src/index.css`

```css
/* You can add your custom CSS here. */
```

### `src/index.js`

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

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

### `src/json.js`

```js
export const json = {
  "elements": [
    {
      "type": "slider",
      "name": "increase-label-count",
      "title": "Auto-generated scale labels",
      "description": "Label count = 11",
      "labelCount": 11
    },
    {
      "type": "slider",
      "name": "custom-labels",
      "title": "Custom scale labels",
      "customLabels": [
        {
          "value": 0,
          "text": "Low"
        },
        {
          "value": 50,
          "text": "Average"
        },
        {
          "value": 100,
          "text": "High"
        }
      ]
    },
    {
      "type": "slider",
      "sliderType": "range",
      "name": "format-labels-and-tooltips",
      "title": "Format tooltips and scale labels",
      "labelFormat": "{0}$",
      "tooltipFormat": "{0}$"
    },
    {
      "type": "slider",
      "sliderType": "range",
      "name": "without-labels",
      "title": "Range slider without scale labels",
      "showLabels": false
    }
  ]
};
```

### `src/theme.js`

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

### `package.json`

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

## Other Frameworks

- [Angular](https://surveyjs.io/form-library/examples/customize-slider-scale-labels/angular.md)
- [Vue 3](https://surveyjs.io/form-library/examples/customize-slider-scale-labels/vue3js.md)
- [jQuery](https://surveyjs.io/form-library/examples/customize-slider-scale-labels/jquery.md)
- [Vanilla JS](https://surveyjs.io/form-library/examples/customize-slider-scale-labels/vanillajs.md)
