File tree 2 files changed +6
-3
lines changed
2 files changed +6
-3
lines changed Original file line number Diff line number Diff line change @@ -23,6 +23,7 @@ export default class Headroom extends Component {
23
23
pinStart : PropTypes . number ,
24
24
style : PropTypes . object ,
25
25
calcHeightOnResize : PropTypes . bool ,
26
+ tag : PropTypes . string ,
26
27
} ;
27
28
28
29
static defaultProps = {
@@ -37,6 +38,7 @@ export default class Headroom extends Component {
37
38
wrapperStyle : { } ,
38
39
pinStart : 0 ,
39
40
calcHeightOnResize : true ,
41
+ tag : 'div' ,
40
42
} ;
41
43
42
44
static getDerivedStateFromProps ( props , state ) {
@@ -332,7 +334,7 @@ export default class Headroom extends Component {
332
334
}
333
335
334
336
render ( ) {
335
- const { className : userClassName , ...divProps } = this . props
337
+ const { className : userClassName , tag : Tag , ...divProps } = this . props
336
338
delete divProps . onUnpin
337
339
delete divProps . onPin
338
340
delete divProps . onUnfix
@@ -394,7 +396,7 @@ export default class Headroom extends Component {
394
396
: 'headroom-wrapper'
395
397
396
398
return (
397
- < div style = { wrapperStyles } className = { wrapperClassName } >
399
+ < Tag style = { wrapperStyles } className = { wrapperClassName } >
398
400
< div
399
401
ref = { this . setRef }
400
402
{ ...rest }
@@ -403,7 +405,7 @@ export default class Headroom extends Component {
403
405
>
404
406
{ this . props . children }
405
407
</ div >
406
- </ div >
408
+ </ Tag >
407
409
)
408
410
}
409
411
}
Original file line number Diff line number Diff line change @@ -76,3 +76,4 @@ Another option is to use CSS. The component has a `headroom` class as well as a
76
76
* ` wrapperStyle ` — pass styles for the wrapper div (this maintains the components vertical space at the top of the page).
77
77
* ` parent ` — provide a custom 'parent' element for scroll events. ` parent ` should be a function which resolves to the desired element.
78
78
* ` pinStart ` — height in px where the header should start and stop pinning. Useful when you have another element above Headroom component.
79
+ * ` tag ` - change the wrapper html element type. Default - ` "div" ` .
You can’t perform that action at this time.
0 commit comments