diff --git a/code/ui/blocks/src/controls/Range.tsx b/code/ui/blocks/src/controls/Range.tsx index adf0aafd11f8..5892e6edf193 100644 --- a/code/ui/blocks/src/controls/Range.tsx +++ b/code/ui/blocks/src/controls/Range.tsx @@ -163,6 +163,17 @@ const RangeLabel = styled.span({ fontVariantNumeric: 'tabular-nums', }); +const RangeCurrentAndMaxLabel = styled(RangeLabel)<{ + numberOFDecimalsPlaces: number; + max: number; +}>(({ numberOFDecimalsPlaces, max }) => ({ + // Fixed width of "current / max" label to avoid slider width changes + // 3 = size of separator " / " + width: `${numberOFDecimalsPlaces + max.toString().length * 2 + 3}ch`, + textAlign: 'right', + flexShrink: 0, +})); + const RangeWrapper = styled.div({ display: 'flex', alignItems: 'center', @@ -208,9 +219,9 @@ export const RangeControl: FC = ({ onChange={handleChange} {...{ name, value, min, max, step, onFocus, onBlur }} /> - + {`${hasValue ? value.toFixed(numberOFDecimalsPlaces) : '--'}`} / {max} - + ); };