Skip to main content
Input components allow users to interact with your Evidence reports by filtering data, selecting options, and triggering actions.

Available Input Components

Dropdown

Single and multi-select dropdowns

DateRange

Date and date range pickers

TextInput

Free-form text input

ButtonGroup

Toggle buttons and radio groups

Checkbox

Boolean checkboxes

Slider

Range and value sliders

Accessing Input Values

All input values are available through the inputs object:
<Dropdown name="category" data={categories} value="category"/>

Selected: {inputs.category.value}
Label: {inputs.category.label}
Use inputs in SQL queries:
filtered_orders
SELECT * FROM orders
WHERE category = '${inputs.category.value}'
Dropdowns allow users to select from a list of options.
```sql categories
SELECT category FROM orders
GROUP BY category
ORDER BY category

### With Custom Title

```markdown
<Dropdown 
  data={years} 
  name="year" 
  value="year" 
  title="Order Year"
/>

Hardcoded Options

<Dropdown name=hardcoded_option>
  <DropdownOption value=1 valueLabel="Option 1"/>
  <DropdownOption value=2 valueLabel="Option 2"/>
  <DropdownOption value=3 valueLabel="Option 3"/>
</Dropdown>

Default Value

<Dropdown 
  name="category" 
  data={categories} 
  value="category" 
  defaultValue="Electronics"
/>

Multi-Select

Allow multiple selections:
<Dropdown 
  name="multi_select" 
  data={categories} 
  value="category" 
  multiple
/>
Use in SQL with IN clause:
filtered_data
SELECT * FROM orders
WHERE category IN ${inputs.multi_select.value}

Select All by Default

<Dropdown 
  name="categories" 
  data={categories} 
  value="category" 
  multiple 
  selectAllByDefault
/>
name
string
required
Unique identifier for accessing the input value
data
QueryResult
Query result containing options (use with value prop)
value
string
Column name to use for option values
title
string
Label displayed above the dropdown
defaultValue
string | string[]
Initial selected value(s)
multiple
boolean
default:"false"
Allow multiple selections
selectAllByDefault
boolean
default:"false"
Select all options initially (multi-select only)
order
string
Column to order options by

DateRange

Date pickers for filtering data by date ranges.

Single Date Picker

<DateRange 
  name="start_date" 
  title="Start Date"
/>

Date Range Picker

<DateRange 
  name="date_range"
  title="Select Date Range"
/>
Access start and end dates:
orders_in_range
SELECT * FROM orders
WHERE order_date >= '${inputs.date_range.start}'
  AND order_date <= '${inputs.date_range.end}'

With Default Dates

<DateRange 
  name="date_range"
  start="2024-01-01"
  end="2024-12-31"
/>

DateRange Props

name
string
required
Unique identifier for accessing the input value
title
string
Label displayed above the date picker
start
string
Default start date (YYYY-MM-DD)
end
string
Default end date (YYYY-MM-DD)

TextInput

Free-form text input for searching and filtering.

Basic TextInput

<TextInput 
  name="search" 
  title="Search Products"
  placeholder="Enter product name..."
/>

Use in Query

search_results
SELECT * FROM products
WHERE product_name ILIKE '%${inputs.search.value}%'

With Default Value

<TextInput 
  name="search" 
  title="Search" 
  defaultValue="Widget"
/>

TextInput Props

name
string
required
Unique identifier for accessing the input value
title
string
Label displayed above the input
placeholder
string
Placeholder text
defaultValue
string
Initial value

ButtonGroup

Toggle buttons for selecting between options.

Basic ButtonGroup

<ButtonGroup name=view_mode>
  <ButtonGroupItem value="chart" label="Chart View"/>
  <ButtonGroupItem value="table" label="Table View"/>
  <ButtonGroupItem value="both" label="Both"/>
</ButtonGroup>

Conditional Display

{#if inputs.view_mode.value === 'chart' || inputs.view_mode.value === 'both'}
  <BarChart data={data} x="category" y="sales"/>
{/if}

{#if inputs.view_mode.value === 'table' || inputs.view_mode.value === 'both'}
  <DataTable data={data}/>
{/if}

ButtonGroup Props

name
string
required
Unique identifier for accessing the input value
title
string
Label displayed above the button group
defaultValue
string
Initial selected value

Checkbox

Boolean checkboxes for on/off options.
<Checkbox 
  name="include_inactive" 
  label="Include Inactive Customers"
/>

Use in Query

customers
SELECT * FROM customers
WHERE {#if !inputs.include_inactive.value}
  status = 'active'
{/if}

Checkbox Props

name
string
required
Unique identifier for accessing the input value
label
string
Label displayed next to checkbox
defaultValue
boolean
default:"false"
Initial checked state

Slider

Range sliders for numeric inputs.

Basic Slider

<Slider 
  name="price_max" 
  title="Max Price" 
  min=0 
  max=1000 
  defaultValue=500
/>

Use in Query

filtered_products
SELECT * FROM products
WHERE price <= ${inputs.price_max.value}

Range Slider

<Slider 
  name="price_range" 
  title="Price Range" 
  min=0 
  max=1000 
  defaultValue={[100, 800]}
  range
/>

Slider Props

name
string
required
Unique identifier for accessing the input value
title
string
Label displayed above the slider
min
number
default:"0"
Minimum value
max
number
default:"100"
Maximum value
step
number
default:"1"
Step increment
defaultValue
number | number[]
Initial value or range
range
boolean
default:"false"
Enable range mode (two handles)

Complete Example

Here’s a complete example using multiple inputs:
# Sales Dashboard

```sql categories
SELECT DISTINCT category FROM orders ORDER BY category
regions
SELECT DISTINCT region FROM orders ORDER BY region

Filters

filtered_orders
SELECT 
  DATE_TRUNC('month', order_date) as month,
  SUM(sales) as total_sales,
  COUNT(*) as num_orders
FROM orders
WHERE category IN ${inputs.category.value}
  AND region IN ${inputs.region.value}
  AND order_date >= '${inputs.date_range.start}'
  AND order_date <= '${inputs.date_range.end}'
GROUP BY 1
ORDER BY 1

Results


## Best Practices

1. **Use descriptive names** - Make input names clear and meaningful
2. **Provide defaults** - Set sensible default values
3. **Add titles** - Label inputs clearly
4. **Multi-select for categories** - Use multi-select for category filters
5. **Date ranges for time** - Use DateRange for time-based filtering
6. **Show selected values** - Display current filter selections
7. **Handle empty results** - Consider what happens with no matching data

## Input State Management

Input values persist in the URL, allowing users to:
- Share filtered views via URL
- Bookmark specific filter combinations
- Navigate back/forward through filter states

## Conditional Logic

Use Svelte's conditional syntax with inputs:

```markdown
{#if inputs.view_type.value === 'summary'}
  <BigValue data={data} value="total"/>
{:else if inputs.view_type.value === 'detail'}
  <DataTable data={data}/>
{:else}
  <BarChart data={data} x="category" y="sales"/>
{/if}

Next Steps

Charts

Visualize filtered data

Custom Components

Build custom input components

Build docs developers (and LLMs) love