diff --git a/docs/src/app/components/pages/components/sliders.jsx b/docs/src/app/components/pages/components/sliders.jsx index 64cd719806ae13..77c8903770b84d 100644 --- a/docs/src/app/components/pages/components/sliders.jsx +++ b/docs/src/app/components/pages/components/sliders.jsx @@ -23,6 +23,12 @@ class SlidersPage extends React.Component { header: 'required', desc: 'The name of the slider. Behaves like the name attribute of an input element.' }, + { + name: 'defaultValue', + type: 'number', + header: 'default: 0', + desc: 'The default value of the slider.' + }, { name: 'description', type: 'string', @@ -125,8 +131,8 @@ class SlidersPage extends React.Component { componentInfo={componentInfo}> - - + + diff --git a/docs/src/app/components/raw-code/sliders-code.txt b/docs/src/app/components/raw-code/sliders-code.txt index 2dcb8ea847b2b1..47cb3c6e6c4f34 100644 --- a/docs/src/app/components/raw-code/sliders-code.txt +++ b/docs/src/app/components/raw-code/sliders-code.txt @@ -1,8 +1,8 @@ //Default // With starting value - - + + // Disabled with fixed value diff --git a/src/slider.jsx b/src/slider.jsx index f71365f66dbb38..dd804ed938bc72 100644 --- a/src/slider.jsx +++ b/src/slider.jsx @@ -51,6 +51,7 @@ const Slider = React.createClass({ propTypes: { name: React.PropTypes.string.isRequired, + defaultValue: valueInRangePropType, description: React.PropTypes.string, disabled: React.PropTypes.bool, error: React.PropTypes.string, @@ -90,7 +91,7 @@ const Slider = React.createClass({ getInitialState() { let value = this.props.value; if (value === undefined) { - value = this.props.min; + value = this.props.defaultValue !== undefined ? this.props.defaultValue : this.props.min; } let percent = (value - this.props.min) / (this.props.max - this.props.min); if (isNaN(percent)) percent = 0;