Control Flow Primitives for number ranges: createNumericRange, mapRange, indexRange, repeat, and their JSX component counterparts.
Stage
Category
Version
Last Updated
3
Control Flow
1.0.0-next.3 (next)
Aug 13, 2026
Terminal window
npmi@solid-primitives/range@next
Control Flow Primitives for displaying a number range or given number of elements.
createNumericRange - Reactively generates a number array for a given range. Convenient companion to the built-in <For>.
repeat - Primitive for mapping a number of elements. Underlying helper for the <Repeat> control flow.
<Repeat> - Control Flow Component for displaying a number of elements. ⚠️ Deprecated — use Solid 2.0's built-in <Repeat>.
mapRange - Primitive for mapping a number range of given start, end, and step values. Underlying helper for the <Range> control flow.
<Range> - Control Flow Component for displaying a number range of elements.
indexRange - Primitive for mapping a number range while keeping previous elements of the same index. Underlying helper for the <IndexRange> control flow.
<IndexRange> - Control Flow Component for displaying a number range of elements, where elements receive a number value as signal.
Reactively generates an array of numbers for the given range. Mirrors the range() API from Python — one argument gives [0, to), two or three give [from, to) with an optional step.
All arguments accept either a plain number or a reactive accessor. Pairs naturally with Solid 2.0's built-in <For>.
Note: The built-in <Repeat> does not diff — it re-renders all children when count changes. If incremental creation/disposal of children is important for your use case, keep using this primitive.
Control Flow component for displaying a specified number of elements.
The times prop is reactive – changing it will only create new elements for added numbers.
Reactively maps a number range of specified start, to and step, with a callback function - underlying helper for the <Range> control flow.
All start, to and step arguments are accessors, and changing them will cause the mapped array to be recalculated, mapping new items for numbers added to the range.
step will become negative (the range will be descending) if to is smaller than start. Range stops at to, it is not included in the range.
const [to, setTo] =createSignal(5);
constmapped=mapRange(
() =>0,
to,
() =>0.5,
number=> {
const [value, setValue] =createSignal(number);
createEffect(
() =>value(),
v=> {
/* react to value */
},
);
return value;
},
);
mapped(); // => [0, 0.5, 1, 1.5, 2...]
setTo(3); // changes the output array, mapping only added numbers
Creates a list of elements by mapping a number range of specified start, to, and step.
All start, to and step props are reactive, and changing them will cause the elements array to be recalculated, creating new elements for numbers added to the range.
start defaults to 0.
to defaults to 1. Range stops at to, it is not included in the range.
step will become negative (the range will be descending) if to is smaller than start.
Primitive for mapping a number range of specified start, to and step, while keeping previous elements of the same index. Underlying helper for the <IndexRange> control flow.
All start, to and step arguments are accessors, and changing them will cause the mapped array to be recalculated, mapping new items appended at the end of the range.
step will become negative (the range will be descending) if to is smaller than start. Range stops at to, it is not included in the range.
const [to, setTo] =createSignal(5);
constmapped=indexRange(
() =>0,
to,
() =>0.5,
number=> {
const [value, setValue] =createSignal(number());
createEffect(
() =>number(),
n=>handleNewNumber(n),
);
return value;
},
);
mapped(); // => [0, 0.5, 1, 1.5, 2...]
setTo(3); // changes the output array, mapping only added indexes
Control Flow Component for displaying a number range of elements, where elements receive a number value as signal, by mapping a number range of specified start, to, and step.
All start, to and step props are reactive, and changing them will cause the elements array to be recalculated, creating new elements for numbers added to the range.
start defaults to 0.
to defaults to 1. Range stops at to, it is not included in the range.
step will become negative (the range will be descending) if to is smaller than start.
Currently the mapRange is handling decremanting ranges by swapping start and to with each other, and then cloning and reversing the mapped array. Doing this during the range mapping could possibly be more performant.
For Ranges, because of how numbers are calculated, fractions might sometimes loose precision. E.g. a range from 1.64 to 2 by 0.2 step would generate numbers: [1.64, 1.8399999999999999] instead of [1.64, 1.84].
Both mapRange and indexRange are missing index arguments in the mapping function.