diff --git a/examples/custom-handles.html b/examples/custom-handles.html
new file mode 100644
index 0000000..b3a4252
--- /dev/null
+++ b/examples/custom-handles.html
@@ -0,0 +1 @@
+placeholder
\ No newline at end of file
diff --git a/examples/custom-handles.js b/examples/custom-handles.js
new file mode 100644
index 0000000..5f856cd
--- /dev/null
+++ b/examples/custom-handles.js
@@ -0,0 +1,44 @@
+require('rc-slider/assets/index.less');
+
+const React = require('react');
+const ReactDOM = require('react-dom');
+const Slider = require('rc-slider');
+
+const wrapperStyle = {width: 400, margin: 50};
+
+const handleStyle = {
+ position: 'absolute',
+ transform: 'translate(-50%, -50%)',
+ cursor: 'pointer',
+ padding: '2px',
+ border: '2px solid #abe2fb',
+ borderRadius: '3px',
+ background: '#fff',
+ fontSize: '14px',
+ textAlign: 'center',
+ zIndex: 3,
+};
+
+const CustomHandle = props => {
+ const style = Object.assign({left: props.offset + '%'}, handleStyle);
+ return (
+
val: {props.value}
+ );
+};
+CustomHandle.propTypes = {
+ value: React.PropTypes.any,
+ offset: React.PropTypes.number,
+};
+
+ReactDOM.render(
+
+
+
+
Slider with custom handle
+
} />
+
+
+ , document.getElementById('__react-content'));
diff --git a/src/Slider.jsx b/src/Slider.jsx
index 22919bc..ce2e94f 100644
--- a/src/Slider.jsx
+++ b/src/Slider.jsx
@@ -1,8 +1,8 @@
-import React from 'react';
+import React, { cloneElement } from 'react';
import {Dom as DomUtils} from 'rc-util';
import classNames from 'classnames';
import Track from './Track';
-import Handle from './Handle';
+import DefaultHandle from './Handle';
import Steps from './Steps';
import Marks from './Marks';
@@ -328,7 +328,7 @@ class Slider extends React.Component {
render() {
const {handle, upperBound, lowerBound} = this.state;
const {className, prefixCls, disabled, vertical, dots, included, range, step,
- marks, max, min, tipTransitionName, tipFormatter, children} = this.props;
+ marks, max, min, Handle, tipTransitionName, tipFormatter, children} = this.props;
const upperOffset = this.calcOffset(upperBound);
const lowerOffset = this.calcOffset(lowerBound);
@@ -336,15 +336,15 @@ class Slider extends React.Component {
const handleClassName = prefixCls + '-handle';
const isNoTip = (step === null) || (tipFormatter === null);
- const upper = ();
+ const upper = cloneElement(Handle, { className: handleClassName,
+ noTip: isNoTip, tipTransitionName: tipTransitionName, tipFormatter: tipFormatter,
+ vertical: vertical, offset: upperOffset, value: upperBound, dragging: handle === 'upperBound' });
let lower = null;
if (range) {
- lower = ();
+ lower = cloneElement(Handle, { className: handleClassName,
+ noTip: isNoTip, tipTransitionName: tipTransitionName, tipFormatter: tipFormatter,
+ vertical: vertical, offset: lowerOffset, value: lowerBound, dragging: handle === 'lowerBound' });
}
const sliderClassName = classNames({
@@ -395,6 +395,7 @@ Slider.propTypes = {
onBeforeChange: React.PropTypes.func,
onChange: React.PropTypes.func,
onAfterChange: React.PropTypes.func,
+ Handle: React.PropTypes.element,
tipTransitionName: React.PropTypes.string,
tipFormatter: React.PropTypes.func,
dots: React.PropTypes.bool,
@@ -411,6 +412,7 @@ Slider.defaultProps = {
max: 100,
step: 1,
marks: {},
+ Handle: ,
onBeforeChange: noop,
onChange: noop,
onAfterChange: noop,