The text highlighter question allows respondents to mark one or more sections of a passage by selecting and highlighting text. This question type is useful for understanding which phrases, ideas, or statements stand out to respondents.
How it works
Respondents are shown a block of text. They can drag to select any portion of the text, which is then highlighted using the configured color. Multiple, non-contiguous selections are supported.
Each selection is recorded as a nonempty, case-sensitive substring of the passage, and the question returns the selections as a ListResponse.
Survey Experience
- Respondents can highlight one or more parts of the passage before continuing.
- Every selection must be a nonempty, case-sensitive substring of
text_to_highlight; empty strings, missing substrings, and non-string selections are rejected. - The highlight color is configurable with the
coloroption.
| Traditional Experience | Traditional Mobile Optimized | Chat Experience |
|---|---|---|
![]() | ![]() | ![]() |
Configuration Options
| Option | Type | Required | Default | Description |
|---|---|---|---|---|
question | string | yes | - | The prompt shown to the user |
text_to_highlight | string | yes | - | The text from which respondents can select and highlight portions |
color | string | no | #FFFF00 (yellow) | Highlight color as exactly six hexadecimal digits prefixed by #; letter case is ignored. Other values raise SurveyValidationError |
default | str, list[str], or list[list[str]] | no | random highlights | Default highlights for test data: a string for one highlight, a list of strings for one full highlight response, or a list of highlight-list candidates — each simulated respondent picks one at random |
number_seconds | int | no | 0 | Seconds to wait before allowing the respondent to continue |
tags | s.tag() | no | - | Used to fill tokens in text and group questions in reports |
id | str | None | no | None | Optional stable identifier for this question |
Example Code
from survey import Survey
s = Survey(**globals())
s.text_highlighter_question(
"Please highlight the parts of the following text that you find most interesting:",
text_to_highlight="The quick brown fox jumps over the lazy dog."
)




