Skip to content

Commit 084923d

Browse files
authored
Add support for a custom className
Allow better styling and support for libraries like TailwindCSS by allowing the user to specify `className`. It's not need for the placeholder as you can already supply a custom component.
1 parent c1cba40 commit 084923d

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

src/index.jsx

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -333,12 +333,13 @@ class LazyLoad extends Component {
333333
height,
334334
children,
335335
placeholder,
336+
className,
336337
classNamePrefix,
337338
style
338339
} = this.props;
339340

340341
return (
341-
<div className={`${classNamePrefix}-wrapper`} ref={this.setRef} style={style}>
342+
<div className={`${classNamePrefix}-wrapper ${className}`} ref={this.setRef} style={style}>
342343
{this.visible ? (
343344
children
344345
) : placeholder ? (
@@ -355,6 +356,7 @@ class LazyLoad extends Component {
355356
}
356357

357358
LazyLoad.propTypes = {
359+
className: PropTypes.string,
358360
classNamePrefix: PropTypes.string,
359361
once: PropTypes.bool,
360362
height: PropTypes.oneOfType([PropTypes.number, PropTypes.string]),
@@ -375,6 +377,7 @@ LazyLoad.propTypes = {
375377
};
376378

377379
LazyLoad.defaultProps = {
380+
className: '',
378381
classNamePrefix: 'lazyload',
379382
once: false,
380383
offset: 0,

0 commit comments

Comments
 (0)