Documentation

Text Highlighter Question

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 color option.
Traditional ExperienceTraditional Mobile OptimizedChat Experience
Text Highlighter Question web Markdown Many OptionsText Highlighter Question mobile Normal TextText Highlighter Question chat Images Markdown
Configuration Options
OptionTypeRequiredDefaultDescription
questionstringyes-The prompt shown to the user
text_to_highlightstringyes-The text from which respondents can select and highlight portions
colorstringno#FFFF00 (yellow)Highlight color as exactly six hexadecimal digits prefixed by #; letter case is ignored. Other values raise SurveyValidationError
defaultstr, list[str], or list[list[str]]norandom highlightsDefault 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_secondsintno0Seconds to wait before allowing the respondent to continue
tagss.tag()no-Used to fill tokens in text and group questions in reports
idstr | NonenoNoneOptional 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."
)