Skip to content

Commit

Permalink
react forward style
Browse files Browse the repository at this point in the history
  • Loading branch information
clementroche committed Jan 9, 2025
1 parent 9cfa597 commit 4f26f63
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 5 deletions.
3 changes: 2 additions & 1 deletion packages/react/src/provider.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ export const ReactLenis = forwardRef<LenisRef, LenisProps>(
options = {},
className,
autoRaf = true,
style,
props,
}: LenisProps,
ref
Expand Down Expand Up @@ -129,7 +130,7 @@ export const ReactLenis = forwardRef<LenisRef, LenisProps>(
{root ? (
children
) : (
<div ref={wrapperRef} className={className} {...props}>
<div ref={wrapperRef} className={className} style={style} {...props}>
<div ref={contentRef}>{children}</div>
</div>
)}
Expand Down
8 changes: 7 additions & 1 deletion packages/react/src/types.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import type Lenis from 'lenis'
import type { LenisOptions, ScrollCallback } from 'lenis'
import type { ComponentPropsWithoutRef, ReactNode } from 'react'
import type { ComponentPropsWithoutRef, CSSProperties, ReactNode } from 'react'

export type LenisContextValue = {
lenis: Lenis
Expand Down Expand Up @@ -34,6 +34,12 @@ export type LenisProps = {
* When `root` is `false`, this will be applied to the wrapper div
*/
className?: string
/**
* Style for the wrapper div
*
* When `root` is `false`, this will be applied to the wrapper div
*/
style?: CSSProperties
/**
* Additional props for the wrapper div
*
Expand Down
7 changes: 6 additions & 1 deletion playground/react/app.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,12 @@ function App() {
return (
<>
{/* <ReactLenis root /> */}
<ReactLenis className="wrapper" root ref={lenisRef}>
<ReactLenis
className="wrapper"
// root
ref={lenisRef}
style={{ height: '100vh', overflowY: 'auto' }}
>
{lorem}
</ReactLenis>
</>
Expand Down
4 changes: 2 additions & 2 deletions playground/react/style.css
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
.lenis {
/* .lenis {
height: 100vh;
overflow-y: auto;
}
} */

0 comments on commit 4f26f63

Please sign in to comment.