Skip to main content

Code Component

The Code component displays syntax-highlighted code snippets. It's useful for programming experiments, code review tasks, or any situation where you need to present formatted code to participants.

Key Features

  • Syntax highlighting for multiple languages
  • Support for JavaScript, Python, HTML, SQL, and more
  • Optional continue button
  • Customizable appearance
  • Line numbers display

When to Use

Use the Code component when you need to:

  • Present code for participants to read or review
  • Display programming problems or puzzles
  • Show code examples in educational experiments
  • Present stimuli for code comprehension studies
  • Display formatted text that benefits from monospace font

Configuration

Basic Settings

SettingDescriptionDefault
CodeThe code snippet to display(required)
LanguageProgramming language for syntax highlightingjavascript
Show Continue ButtonDisplay a button to proceedfalse
Continue Button TextText for the continue button"Continue"

Supported Languages

The Code component supports syntax highlighting for:

  • JavaScript / TypeScript
  • Python
  • HTML / CSS
  • SQL
  • JSON
  • Markdown
  • C / C++ / C#
  • Java
  • Go
  • Rust
  • And many more...

Appearance Options

SettingDescriptionDefault
ThemeColor theme for syntax highlightingdark
Show Line NumbersDisplay line numberstrue
Font SizeCode font size14px
Max HeightMaximum height before scrollingnone

Examples

JavaScript Code

Python Code

HTML Code

With Continue Button

Data Collection

When using a continue button, the component stores:

  • Response Time: Time from display to button click
  • Timestamps: When displayed and when continued

Example data structure:

{
"continued": true,
"responseTime": 12456,
"timestamps": {
"displayed": 1621453287000,
"continued": 1621453299456
}
}

Best Practices

  1. Choose the Right Language: Select the correct language for proper syntax highlighting
  2. Readable Font Size: Ensure code is large enough to read comfortably
  3. Appropriate Length: Keep code snippets focused on the relevant portion
  4. Context: Provide explanation text before or after the code if needed
  5. Line Numbers: Enable line numbers when you'll reference specific lines

Use Cases

Code Comprehension Study

Display code and ask participants to predict output or identify bugs.

Programming Education

Show example code with explanations as part of learning materials.

Code Review Task

Present code snippets and ask participants to evaluate quality or find issues.

Algorithm Comparison

Show different implementations of the same algorithm.