@@ -187,6 +187,7 @@ function renderSliders(inputRange) {
187187 ariaLabelledby = { inputRange . props . ariaLabelledby }
188188 ariaControls = { inputRange . props . ariaControls }
189189 classNames = { classNames }
190+ formatLabel = { inputRange . formatLabel }
190191 key = { key }
191192 maxValue = { maxValue }
192193 minValue = { minValue }
@@ -240,6 +241,7 @@ export default class InputRange extends React.Component {
240241
241242 // Auto-bind
242243 autobind ( [
244+ 'formatLabel' ,
243245 'handleInteractionEnd' ,
244246 'handleInteractionStart' ,
245247 'handleKeyDown' ,
@@ -367,6 +369,21 @@ export default class InputRange extends React.Component {
367369 this . updateValue ( key , value ) ;
368370 }
369371
372+ /**
373+ * Format label
374+ * @param {number } labelValue - Label value
375+ * @return {string } Formatted label value
376+ */
377+ formatLabel ( labelValue ) {
378+ const { formatLabel, labelPrefix, labelSuffix } = this . props ;
379+
380+ if ( formatLabel ) {
381+ return formatLabel ( labelValue , { labelPrefix, labelSuffix } ) ;
382+ }
383+
384+ return `${ labelPrefix } ${ labelValue } ${ labelSuffix } ` ;
385+ }
386+
370387 /**
371388 * Handle any mousemove event received by the slider
372389 * @param {SyntheticEvent } event - User event
@@ -548,7 +565,8 @@ export default class InputRange extends React.Component {
548565 onTouchStart = { this . handleTouchStart } >
549566 < Label
550567 className = { classNames . labelMin }
551- containerClassName = { classNames . labelContainer } >
568+ containerClassName = { classNames . labelContainer }
569+ formatLabel = { this . formatLabel } >
552570 { this . props . minValue }
553571 </ Label >
554572
@@ -563,7 +581,8 @@ export default class InputRange extends React.Component {
563581
564582 < Label
565583 className = { classNames . labelMax }
566- containerClassName = { classNames . labelContainer } >
584+ containerClassName = { classNames . labelContainer }
585+ formatLabel = { this . formatLabel } >
567586 { this . props . maxValue }
568587 </ Label >
569588
@@ -581,6 +600,9 @@ export default class InputRange extends React.Component {
581600 * @property {Function } classNames
582601 * @property {Function } defaultValue
583602 * @property {Function } disabled
603+ * @property {Function } formatLabel
604+ * @property {Function } labelPrefix
605+ * @property {Function } labelSuffix
584606 * @property {Function } maxValue
585607 * @property {Function } minValue
586608 * @property {Function } name
@@ -595,6 +617,9 @@ InputRange.propTypes = {
595617 classNames : React . PropTypes . objectOf ( React . PropTypes . string ) ,
596618 defaultValue : maxMinValuePropType ,
597619 disabled : React . PropTypes . bool ,
620+ formatLabel : React . PropTypes . func ,
621+ labelPrefix : React . PropTypes . string ,
622+ labelSuffix : React . PropTypes . string ,
598623 maxValue : maxMinValuePropType ,
599624 minValue : maxMinValuePropType ,
600625 name : React . PropTypes . string ,
@@ -610,6 +635,8 @@ InputRange.propTypes = {
610635 * @property {Object.<string, string> } defaultClassNames
611636 * @property {Range|number } defaultValue
612637 * @property {boolean } disabled
638+ * @property {string } labelPrefix
639+ * @property {string } labelSuffix
613640 * @property {number } maxValue
614641 * @property {number } minValue
615642 * @property {number } step
@@ -619,6 +646,8 @@ InputRange.defaultProps = {
619646 classNames : defaultClassNames ,
620647 defaultValue : 0 ,
621648 disabled : false ,
649+ labelPrefix : '' ,
650+ labelSuffix : '' ,
622651 maxValue : 10 ,
623652 minValue : 0 ,
624653 step : 1 ,
0 commit comments