Skip to content

Commit

Permalink
Add support for a custom className
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
AlexMeah authored Nov 14, 2020
1 parent c1cba40 commit 084923d
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion src/index.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -333,12 +333,13 @@ class LazyLoad extends Component {
height,
children,
placeholder,
className,
classNamePrefix,
style
} = this.props;

return (
<div className={`${classNamePrefix}-wrapper`} ref={this.setRef} style={style}>
<div className={`${classNamePrefix}-wrapper ${className}`} ref={this.setRef} style={style}>
{this.visible ? (
children
) : placeholder ? (
Expand All @@ -355,6 +356,7 @@ class LazyLoad extends Component {
}

LazyLoad.propTypes = {
className: PropTypes.string,
classNamePrefix: PropTypes.string,
once: PropTypes.bool,
height: PropTypes.oneOfType([PropTypes.number, PropTypes.string]),
Expand All @@ -375,6 +377,7 @@ LazyLoad.propTypes = {
};

LazyLoad.defaultProps = {
className: '',
classNamePrefix: 'lazyload',
once: false,
offset: 0,
Expand Down

0 comments on commit 084923d

Please sign in to comment.