Input Cell
The Input Cell lets you capture interactive input from viewers of your document or app. These inputs can be referenced in other cells (Python, SQL, Prompt, etc.) to create dynamic, data-driven workflows.
You can choose between four input types:
- Text – Accepts freeform text input.
- Number – Accepts numeric input, with optional increment size.
- Slider – Allows selection of a number within a range (min, max, and step size configurable).
- Date – Lets the user select a date (and optionally, time).
General Settings
All input types share some common settings:
- Label – Displayed to viewers so they know what the input controls.
- Value – Default value when the doc/app is loaded.
- Type-specific settings:
- Text: Toggle multiline input.
- Number: Increment size for +/- adjustments.
- Slider: Min, max, and step size.
- Date: Option to include time in addition to date.
Referencing Input Values
When a viewer changes the input, the new value is available to other cells via its variable name, shown under the cell (e.g., input_0
).
You can insert it into:
- SQL cells:
SELECT * FROM sales.csv LIMIT {{input_0}}
- Python cells:
rows_to_show = livedocs.inputs["input_0"]
df.head(rows_to_show)
- Prompt cells:
User prompt: Show me the sales trend for the last {{input_2}} months.
Creative Use Cases
- Dynamic Dashboard Filters – Use a date input to filter SQL queries:
SELECT * FROM orders WHERE order_date >= '{{input_3}}'
-
Parameterizing Models – Use a slider to control a Python machine learning model hyperparameter (e.g., number of clusters in k-means).
-
Interactive AI Prompts – Feed user-provided text into an LLM prompt cell to change the question or context dynamically.
-
What-If Analysis – Use a number input to adjust revenue projections or change assumptions in calculations.