-
Notifications
You must be signed in to change notification settings - Fork 9
feat: added doc for scroll-area #1249
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change | ||
---|---|---|---|---|
@@ -0,0 +1,138 @@ | ||||
--- | ||||
title: ScrollArea | ||||
description: ScrollArea component | ||||
--- | ||||
|
||||
The `ScrollArea` component provides a UI element for creating scrollable areas with custom scrollbars. It includes various customization options. | ||||
|
||||
import { DocsPage } from "@/components/docs-page"; | ||||
|
||||
<DocsPage.ComponentExample | ||||
client:only | ||||
code={`<ScrollArea className="h-24 w-64"> | ||||
<div className="p-4"> | ||||
<p>Scrollable content goes here.</p> | ||||
<p>Scrollable content goes here.</p> | ||||
<p>Scrollable content goes here.</p> | ||||
<p>Scrollable content goes here.</p> | ||||
<p>Scrollable content goes here.</p> | ||||
</div> | ||||
</ScrollArea>`} | ||||
/> | ||||
|
||||
## Usage | ||||
|
||||
```typescript jsx | ||||
import { ScrollArea } from '@harnessio/ui/components' | ||||
|
||||
// ... | ||||
|
||||
return ( | ||||
<ScrollArea | ||||
className="h-64 w-64" | ||||
viewportClassName="custom-viewport" | ||||
> | ||||
<div className="p-4"> | ||||
<p>Scrollable content goes here.</p> | ||||
<p>Scrollable content goes here.</p> | ||||
<p>Scrollable content goes here.</p> | ||||
<p>Scrollable content goes here.</p> | ||||
<p>Scrollable content goes here.</p> | ||||
</div> | ||||
</ScrollArea> | ||||
) | ||||
``` | ||||
|
||||
## Anatomy | ||||
|
||||
The ScrollArea component can be used to create scrollable areas. | ||||
|
||||
```typescript jsx | ||||
<ScrollArea className="h-64 w-64"> | ||||
<div className="p-4"> | ||||
<p>Scrollable content goes here.</p> | ||||
<p>Scrollable content goes here.</p> | ||||
<p>Scrollable content goes here.</p> | ||||
<p>Scrollable content goes here.</p> | ||||
<p>Scrollable content goes here.</p> | ||||
</div> | ||||
</ScrollArea> | ||||
``` | ||||
|
||||
## API Reference | ||||
|
||||
### ScrollArea | ||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Can drop the name from here for single-part components.
Suggested change
|
||||
|
||||
The `ScrollArea` component serves as the main container for the scrollable area. | ||||
|
||||
```typescript jsx | ||||
<ScrollArea | ||||
type="hover" // [Optional] Scrollbar visibility behavior ('auto' | 'always' | 'scroll' | 'hover') | ||||
dir="ltr" // [Optional] Reading direction ('ltr' | 'rtl') | ||||
scrollHideDelay={600} // [Optional] Delay before hiding scrollbar (in ms) | ||||
className="h-[300px] w-[400px]" // [Optional] Container dimensions and styles | ||||
viewportClassName="p-4" // [Optional] Viewport styles | ||||
scrollThumbClassName="bg-gray-400" // [Optional] Scroll thumb styles | ||||
asChild={false} // [Optional] Change the rendered element | ||||
Comment on lines
+70
to
+76
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Use |
||||
> | ||||
{/* Scrollable content */} | ||||
</ScrollArea> | ||||
``` | ||||
|
||||
<DocsPage.PropsTable | ||||
props={[ | ||||
{ | ||||
name: "children", | ||||
description: "The content to display inside the scroll area", | ||||
required: true, | ||||
value: "ReactNode", | ||||
}, | ||||
{ | ||||
name: "type", | ||||
description: "Describes the nature of scrollbar visibility", | ||||
required: false, | ||||
value: "'auto' | 'always' | 'scroll' | 'hover'", | ||||
defaultValue: "'hover'", | ||||
}, | ||||
{ | ||||
name: "dir", | ||||
description: "The reading direction of the scroll area", | ||||
required: false, | ||||
value: "'ltr' | 'rtl'", | ||||
}, | ||||
{ | ||||
name: "scrollHideDelay", | ||||
description: | ||||
"The duration from when the user stops interacting with scrollbar to when it's hidden", | ||||
required: false, | ||||
value: "number", | ||||
defaultValue: "600", | ||||
}, | ||||
{ | ||||
name: "className", | ||||
description: "Additional class names for the scroll area container", | ||||
required: false, | ||||
value: "string", | ||||
}, | ||||
{ | ||||
name: "viewportClassName", | ||||
description: | ||||
"Class names for the viewport element that wraps the content", | ||||
required: false, | ||||
value: "string", | ||||
}, | ||||
{ | ||||
name: "scrollThumbClassName", | ||||
description: "Class names for the scroll thumb element", | ||||
required: false, | ||||
value: "string", | ||||
}, | ||||
{ | ||||
name: "asChild", | ||||
description: | ||||
"Change the default rendered element for the one passed as a child", | ||||
required: false, | ||||
value: "boolean", | ||||
}, | ||||
]} | ||||
/> |
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. While we're editing this file, can we remove |
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No need for an
Anatomy
section for single part components.