number
A single numeric input. Six visual styles — from a plain input to sliders, steppers, and a dial — covering everything from currency to NPS.
What number is
number collects one numeric value. The respondent types or picks a
number; the runtime stores it as a number. min and max constrain
the value range, not the count of selections — there’s only ever
one value. Decimal entry is off by default; turn it on with
decimal: True.
- qid: QAge
type: number
text: How old are you?
label.suffix: years
min: 13
max: 120
Properties
| Property | Values | Notes |
|---|---|---|
qid | string | Required. Unique within the survey. |
type | number | Required. |
title, text, instruction | renderable | Visible content. Use {{ }} to pipe runtime values. HTML allowed. |
required | True | False | Default True. |
default.errors | True | False | custom string | Default True. |
validation | code block | Python; call fail() to reject. No default. |
readonly | True | False | Default False. Set True to render the question but disable input — the respondent sees it but can’t change the value. Pair with visibility: hide to fully hide a helper question. |
visibility | show | hide | Default show. |
style | input | slider | sliderTicks | stepper | dial | dropdown | Default input. See Styles below. |
min | number | Lower bound on the value. No default — unbounded unless set. |
max | number | Upper bound on the value. No default — unbounded unless set. |
decimal | True | False | Default False. Set True to allow fractional values. |
decimal.places | integer | Cap precision when decimal: True. No default — unlimited. |
label.prefix | string | Decoration on the left of the input (e.g. $). |
label.suffix | string | Decoration on the right (e.g. years, %). |
input.size | integer | Width of the input box in characters. Default sizes itself to the container. |
input.source | default | js | Default default. Set js for JS-fed values. |
custom | code block | Custom runtime block. No default. |
Skin-specific properties
These properties only have effect under a specific style:. Setting
them with any other style is ignored.
| Property | Used with | Values | Notes |
|---|---|---|---|
stepper.step | style: stepper | number | Increment per − / + press. Default 1. Set higher (e.g. 5, 6) when the respondent should jump by larger amounts. |
slider.ticks | style: sliderTicks | configuration | Tick-mark configuration along the slider — count, labels, position. See Skin variants for the full shape. |
Methods & accessors
Accessors
| Expression | Returns | Meaning |
|---|---|---|
Q.value | number | The numeric answer. None if unanswered. |
Q.answered | bool | True once the respondent has entered a value (or a script set one). |
Q.notAnswered | bool | Inverse of answered. |
Methods
| Expression | Returns | Meaning |
|---|---|---|
Q.set(N) | None | Set the value to a number (integer or float). Used in scripts on hidden helpers. |
Q.reset() | None | Clear the value. |
number.set() accepts a number — integer or float (when
decimal: True). Strings are rejected; for textual input use
open.
Numeric operations on Q.value
Q.value is a Python number, so the standard arithmetic and
comparison operators are available:
| Expression | Returns | Meaning |
|---|---|---|
Q.value > 18 | bool | Greater than. |
Q.value <= 65 | bool | Less than or equal. |
Q.value == 0 | bool | Equality. |
Q.value % 6 == 0 | bool | Multiple-of check via modulo. |
abs(Q.value) | number | Absolute value. |
round(Q.value) | number | Round to nearest integer. |
round(Q.value, 2) | number | Round to 2 decimal places. |
See Builtins & operators for the full math reference.
Skins
Six visual styles. Pick by the value’s range, the device, and the authoring intent.
input Input (default) slider Slider sliderTicks Slider + Ticks stepper Stepper dial Dial dropdown Dropdown The exact appearance is driven by theme tokens — colours, radii, fonts. See Customisation and Skin variants.
See it work
A working preview using each interactive style. Type, drag, or tap.
Input
QSpend.answeredFalseQSpend.valueNoneQSpend.selected{}QSpend.selectedLabelNoneQSpend.selected.size0QSpend.answeredFalseQSpend.valueNone- qid: QSpend
type: number
text: How much did you spend last month?
label.prefix: $
min: 0
max: 10000
Slider
QNps.answeredFalseQNps.valueNoneQNps.selected{}QNps.selectedLabelNoneQNps.selected.size0QNps.answeredFalseQNps.valueNone- qid: QNps
type: number
text: How likely are you to recommend us?
style: slider
min: 0
max: 10
Stepper
QPeople.answeredFalseQPeople.valueNoneQPeople.selected{}QPeople.selectedLabelNoneQPeople.selected.size0QPeople.answeredFalseQPeople.valueNone- qid: QPeople
type: number
text: How many people are in your household?
style: stepper
min: 1
max: 20
Methods & accessors — live
Type a value below and watch each expression evaluate.
QAge.answered → — QAge.notAnswered → — QAge.value → — QAge.value > 18 → — QAge.value >= 65 → — QAge.value < 13 → — QAge.value % 5 == 0 → — A few things to notice:
valueis a number, not a string. Pick42andvalueis42, not"42". Compare with unquoted numbers:QAge.value > 18, not> "18".valueisNonewhen unanswered. All comparisons againstNoneevaluateFalse, soQAge.value > 0won’t accidentally match an unanswered question — but it also won’t match the inverse. UseQAge.answeredas the explicit gate when needed.- Comparisons compose.
if 18 <= QAge.value <= 65: …is the natural Python way to check a range — same syntax in scripts andif:properties.
Examples
Currency input
- qid: QSpend
type: number
text: How much did you spend last month?
label.prefix: $
label.suffix: USD
decimal: True
decimal.places: 2
min: 0
label.prefix and label.suffix decorate the input visually; they
don’t affect the stored value (still a number). decimal: True plus
decimal.places: 2 allows two decimal places — perfect for currency.
Likelihood scale (NPS)
- qid: QNps
type: number
text: How likely are you to recommend us?
style: slider
min: 0
max: 10
- qid: hNpsBucket
type: single
options:
1: Detractor
2: Passive
3: Promoter
visibility: hide
readonly: True
required: False
- script: |
if QNps.value <= 6: hNpsBucket.set(1) # Detractor
elif QNps.value <= 8: hNpsBucket.set(2) # Passive
else: hNpsBucket.set(3) # Promoter
The slider style is a natural fit for 0–10 NPS scales. The hidden
helper question hNpsBucket derives the standard NPS bucket from the
score, so analysts get a clean categorical column alongside the raw
score.
Age gate
- qid: QAge
type: number
text: How old are you?
label.suffix: years
min: 13
max: 120
- script: |
if QAge.value < 18:
endSurvey(status="terminate", redirect="https://example.com/under18")
min: 13 rejects nonsensical entries at the input level; the
script-level termination handles “valid number but doesn’t qualify”.
Range validation with custom message
- qid: QYears
type: number
text: How many years of experience do you have?
label.suffix: years
min: 0
max: 60
validation: |
if QYears.value > 50:
fail("Please double-check — that seems unusually high.")
min/max enforce hard bounds; validation: adds soft checks with
custom messages. Both run, with min/max first.
Multiple-of constraint
- qid: QQuantity
type: number
text: How many cases? (must be a multiple of 6)
style: stepper
stepper.step: 6
min: 0
max: 600
validation: |
if QQuantity.value % 6 != 0:
fail("Please enter a multiple of 6.")
stepper.step: 6 makes the +/- buttons jump by 6 — guides the
respondent toward valid values. The validation: block is a defensive
backstop in case the field is edited in some other way.
Hidden numeric helper
- qid: QAge
type: number
text: How old are you?
min: 13
max: 120
- qid: hAgeBand
type: number
visibility: hide
readonly: True
required: False
- script: |
if QAge.value < 25: hAgeBand.set(1)
elif QAge.value < 45: hAgeBand.set(2)
elif QAge.value < 65: hAgeBand.set(3)
else: hAgeBand.set(4)
A bucketed age value alongside the raw age. Both export.
Conditional follow-up
- qid: QSpend
type: number
text: How much did you spend last month?
label.prefix: $
- qid: QSpendDetail
type: open
text: What was that mostly on?
if: QSpend.value > 100
style: textarea
QSpendDetail only shows when the spend is over $100. Numeric
comparisons in if: are clean and read like English.
Export
number exports as a single column:
| What | Column |
|---|---|
| The numeric value | qid (e.g. QAge) — number |
Empty answers (when required: False and the respondent leaves it
blank) export as null. Decimal values respect decimal.places —
extra digits are truncated.
See also
- numberList — multiple numeric inputs per question, one per row.
- gridNumber — 2D numeric grid (rows × cols).
- open — for textual input.
- Constraints —
min/max/decimal,validation. - Builtins & operators — math, comparisons.
- Skin variants — visual reference across types.