A customizable range slider component with histogram visualization for Retool applications. Perfect for filtering data ranges and visualizing distributions.
- Interactive Range Selection: Drag handles to select min/max values
- Histogram Visualization: Display data distribution alongside the slider
- Multiple Scale Types: Linear, logarithmic, and square root scales
- Flexible Data Input: Supports multiple data formats from Retool queries
- Custom Formatting: Define custom value formatters with JavaScript functions
- Fully Customizable: Colors, labels, and step sizes
- Negative Value Support: Optional display of negative values in histogram
- Click-to-Select: Click histogram bars to quickly select ranges
-
Clone this repository or navigate to your project directory
-
Install dependencies:
npm install
-
Log in to Retool:
npx retool-ccl login
Note: You'll need an API access token with read and write scopes for Custom Component Libraries.
-
Start development mode:
npm run dev
-
Deploy your component:
npm run deploy
-
Switch component versions:
To pin your app to the component version you just published, navigate to the Custom Component settings in your Retool app and change dev to the latest version.
The component exposes the following properties in Retool:
| Property | Type | Default | Description |
|---|---|---|---|
min |
Number | 0 | Minimum value of the range slider |
max |
Number | 100 | Maximum value of the range slider |
defaultStart |
Number | 25 | Initial start value of selected range |
defaultEnd |
Number | 75 | Initial end value of selected range |
step |
Number | 1 | Increment step size for the slider |
label |
String | "Label" | Label displayed above the slider |
| Property | Type | Default | Description |
|---|---|---|---|
distributionData |
Array | [] | Array of buckets: [{ min, max, count }] |
histogramScale |
Enum | "linear" | Scale type: "linear", "logarithmic", or "sqrt" |
showNegativeValues |
Boolean | false | Show negative values below x-axis when min or max is negative |
| Property | Type | Default | Description |
|---|---|---|---|
primaryColor |
String | #f97316 | Main color for selected range and active elements |
primaryLightColor |
String | #fb923c | Lighter shade for hover states |
secondaryColor |
String | #d1d5db | Color for inactive/unselected elements |
backgroundColor |
String | #f3f4f6 | Background color for the component |
textColor |
String | #1f2937 | Color for text labels and values |
tooltip |
String | #1f2937 | Color for tooltip text |
| Property | Type | Default | Description |
|---|---|---|---|
formatterFunction |
String | "" | JavaScript function to format values (e.g., "v => \$${v}`"`) |
| Property | Type | Description |
|---|---|---|
selectedRange |
Object | Current selected range: { start: number, end: number } |
| Event | Description |
|---|---|
rangeChanged |
Triggered when the selected range changes |
- Add the Custom Range Slider to your Retool app
- Configure basic range:
- Set
minto 0 - Set
maxto 100 - Set
labelto "Price Range"
- Set
Connect a query that returns distribution data in any of these formats:
Format 1: Array of objects
[
{ "min": 0, "max": 10, "count": 5 },
{ "min": 10, "max": 20, "count": 8 },
{ "min": 20, "max": 30, "count": 3 }
]Format 2: Object of arrays
{
"bucket_index": [0, 1, 2],
"bucket_min": [0, 10, 20],
"bucket_max": [10, 20, 30],
"count": [5, 8, 3]
}Set distributionData to {{ query1.dataArray }}
Add a custom formatter to display values as currency:
- Set
formatterFunctionto"v => \$${v.toFixed(2)}`"`
Or format as dates using moment:
- Set
formatterFunctionto"v => moment.unix(v).format('MMM DD')"
In case you have negative to positive range:
Configure the styling you want:
Access the selected range in other components or queries:
{{ customRangeSlider1.selectedRange.start }}{{ customRangeSlider1.selectedRange.end }}
Use the rangeChanged event to trigger queries when the range changes.
- Node.js >= 20.0.0
- Retool developer account
- Run
npm installto install dependencies - Make changes to components in the
srcdirectory - Run
npm run devto test your changes - Run
npm run deployto deploy to Retool
src/index.tsx- Main entry pointsrc/CustomRangeSlider.tsx- Main componentsrc/components/- Reusable sub-components (Histogram, RangeSlider)src/utils/- Utility functions (data transformers, formatters)src/types/- TypeScript type definitions
This project is licensed under the MIT License.
Created by Stackdrop



