RangeSlider
A draggable track for picking a number, or a low-and-high pair, inside a known range where the exact value matters less than the relative one.
Preview
Code
Example.jsx
import { useState, useCallback } from 'react';
import { Card, BlockStack, InlineStack, RangeSlider, Text, Badge, Divider } from '@shopify/polaris';
const PRICE_MIN = 0;
const PRICE_MAX = 200;
export const Example = () => {
const [discount, setDiscount] = useState(25);
const [priceRange, setPriceRange] = useState([40, 120]);
const [opacity, setOpacity] = useState(80);
const changeRange = useCallback((value) => setPriceRange(value), []);
return (
<Card>
<BlockStack gap="500">
<BlockStack gap="200">
<RangeSlider
label="Discount percentage"
value={discount}
onChange={setDiscount}
min={0}
max={90}
step={5}
output
suffix={
<Text as="span" variant="bodyMd" tone="subdued">
{discount}%
</Text>
}
helpText="Applied to every product in the Summer essentials collection."
/>
<InlineStack gap="200" blockAlign="center">
<Badge tone={discount >= 50 ? 'warning' : 'info'}>
{discount >= 50 ? 'Deep discount' : 'Standard discount'}
</Badge>
<Text as="span" tone="subdued">
A $40.00 item sells for ${(40 * (1 - discount / 100)).toFixed(2)}.
</Text>
</InlineStack>
</BlockStack>
<Divider />
<RangeSlider
label="Price range filter"
value={priceRange}
onChange={changeRange}
min={PRICE_MIN}
max={PRICE_MAX}
step={5}
output
prefix={<Text as="span" tone="subdued">${priceRange[0]}</Text>}
suffix={<Text as="span" tone="subdued">${priceRange[1]}</Text>}
helpText="Only show products inside this price band on the collection page."
/>
<Divider />
<RangeSlider
label="Banner opacity"
value={opacity}
onChange={setOpacity}
min={10}
max={100}
output
/>
<div
style={{
height: '3rem',
borderRadius: 'var(--p-border-radius-200, 0.5rem)',
background: 'var(--p-color-bg-fill-brand, #303030)',
opacity: opacity / 100,
}}
/>
</BlockStack>
</Card>
);
};