diff --git a/README.md b/README.md
index 7c61fe2..839d015 100644
--- a/README.md
+++ b/README.md
@@ -188,6 +188,12 @@ If `accordion` is true, only one panel can be open. Opening another panel will
false |
forced render of content in panel, not lazy render after clicking on header |
+
+ | extra |
+ String | ReactNode |
+ |
+ Content to render in the right of the panel header |
+
diff --git a/assets/index.less b/assets/index.less
index bf73e03..87600f3 100644
--- a/assets/index.less
+++ b/assets/index.less
@@ -38,6 +38,8 @@
}
> .@{prefixCls}-header {
+ display: flex;
+ align-items: center;
line-height: 22px;
padding: 10px 16px;
color: #666;
@@ -50,6 +52,10 @@
vertical-align: middle;
margin-right: 8px;
}
+
+ .@{prefixCls}-extra {
+ margin: 0 16px 0 auto;
+ }
}
}
@@ -85,6 +91,8 @@
> .@{prefixCls}-header {
.arrow {
+ position: relative;
+ top: 2px;
#arrow > .bottom(3px, 4px, #666);
margin-right: 6px;
}
diff --git a/examples/simple.js b/examples/simple.js
index 6055b96..8879496 100644
--- a/examples/simple.js
+++ b/examples/simple.js
@@ -60,6 +60,12 @@ class Test extends React.Component {
);
+ items.push(
+ Extra Node}>
+ Panel with extra
+
+ );
+
return items;
}
diff --git a/src/Panel.jsx b/src/Panel.jsx
index 09a8c27..11ba89d 100644
--- a/src/Panel.jsx
+++ b/src/Panel.jsx
@@ -40,6 +40,7 @@ class CollapsePanel extends Component {
accordion,
forceRender,
expandIcon,
+ extra,
} = this.props;
const headerCls = classNames(`${prefixCls}-header`, {
[headerClass]: headerClass,
@@ -66,6 +67,7 @@ class CollapsePanel extends Component {
>
{showArrow && (icon || )}
{header}
+ {extra && ({extra}
)}
{
ReactDOM.render(
first
- second
+ ExtraSpan}>second
third
, node, function init() {
collapse = this;
@@ -65,6 +65,12 @@ describe('collapse', () => {
expect(findDOMNode(collapse, 'rc-collapse-item-active').length).to.be(0);
});
+ it('extra works', () => {
+ const extraNodes = findDOMNode(collapse, 'rc-collapse-extra');
+ expect(extraNodes.length).to.be(1);
+ expect(extraNodes[0].innerHTML).to.equal('ExtraSpan');
+ });
+
it('onChange works', (done) => {
changeHook = (d) => {
expect(d).to.eql(['2']);