-
Notifications
You must be signed in to change notification settings - Fork 4.9k
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
docs(scroll-area): add example for horizontal scroll area #1515
Merged
kodiakhq
merged 5 commits into
shadcn-ui:main
from
gregermendle:gregermendle/scroll-area-horizontal-docs
Oct 21, 2023
Merged
Changes from all commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
5025ffc
docs(scroll-area): add example for horizontal scroll area
gregermendle 7f1b09a
fix(scroll-area): improper horizontal scroll bar width
gregermendle 32d9d23
refactor(scroll-area): exchange tooltip for caption in horizontal scr…
gregermendle 9311cf5
Merge branch 'main' into gregermendle/scroll-area-horizontal-docs
gregermendle 611c7cf
Merge branch 'main' into gregermendle/scroll-area-horizontal-docs
shadcn File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
53 changes: 53 additions & 0 deletions
53
apps/www/registry/default/example/scroll-area-horizontal-demo.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
import * as React from "react" | ||
import Image from "next/image" | ||
|
||
import { ScrollArea, ScrollBar } from "@/registry/default/ui/scroll-area" | ||
|
||
export interface Artwork { | ||
artist: string | ||
art: string | ||
} | ||
|
||
export const works: Artwork[] = [ | ||
{ | ||
artist: "Ornella Binni", | ||
art: "https://images.unsplash.com/photo-1465869185982-5a1a7522cbcb?auto=format&fit=crop&w=300&q=80", | ||
}, | ||
{ | ||
artist: "Tom Byrom", | ||
art: "https://images.unsplash.com/photo-1548516173-3cabfa4607e9?auto=format&fit=crop&w=300&q=80", | ||
}, | ||
{ | ||
artist: "Vladimir Malyavko", | ||
art: "https://images.unsplash.com/photo-1494337480532-3725c85fd2ab?auto=format&fit=crop&w=300&q=80", | ||
}, | ||
] | ||
|
||
export default function ScrollAreaHorizontalDemo() { | ||
return ( | ||
<ScrollArea className="w-96 whitespace-nowrap rounded-md border"> | ||
<div className="flex w-max space-x-4 p-4"> | ||
{works.map((artwork) => ( | ||
<figure key={artwork.artist} className="shrink-0"> | ||
<div className="overflow-hidden rounded-md"> | ||
<Image | ||
src={artwork.art} | ||
alt={`Photo by ${artwork.artist}`} | ||
className="aspect-[3/4] h-fit w-fit object-cover" | ||
width={300} | ||
height={400} | ||
/> | ||
</div> | ||
<figcaption className="pt-2 text-xs text-muted-foreground"> | ||
Photo by{" "} | ||
<span className="font-semibold text-foreground"> | ||
{artwork.artist} | ||
</span> | ||
</figcaption> | ||
</figure> | ||
))} | ||
</div> | ||
<ScrollBar orientation="horizontal" /> | ||
</ScrollArea> | ||
) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
53 changes: 53 additions & 0 deletions
53
apps/www/registry/new-york/example/scroll-area-horizontal-demo.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
import * as React from "react" | ||
import Image from "next/image" | ||
|
||
import { ScrollArea, ScrollBar } from "@/registry/new-york/ui/scroll-area" | ||
|
||
export interface Artwork { | ||
artist: string | ||
art: string | ||
} | ||
|
||
export const works: Artwork[] = [ | ||
{ | ||
artist: "Ornella Binni", | ||
art: "https://images.unsplash.com/photo-1465869185982-5a1a7522cbcb?auto=format&fit=crop&w=300&q=80", | ||
}, | ||
{ | ||
artist: "Tom Byrom", | ||
art: "https://images.unsplash.com/photo-1548516173-3cabfa4607e9?auto=format&fit=crop&w=300&q=80", | ||
}, | ||
{ | ||
artist: "Vladimir Malyavko", | ||
art: "https://images.unsplash.com/photo-1494337480532-3725c85fd2ab?auto=format&fit=crop&w=300&q=80", | ||
}, | ||
] | ||
|
||
export default function ScrollAreaHorizontalDemo() { | ||
return ( | ||
<ScrollArea className="w-96 whitespace-nowrap rounded-md border"> | ||
<div className="flex w-max space-x-4 p-4"> | ||
{works.map((artwork) => ( | ||
<figure key={artwork.artist} className="shrink-0"> | ||
<div className="overflow-hidden rounded-md"> | ||
<Image | ||
src={artwork.art} | ||
alt={`Photo by ${artwork.artist}`} | ||
className="aspect-[3/4] h-fit w-fit object-cover" | ||
width={300} | ||
height={400} | ||
/> | ||
</div> | ||
<figcaption className="pt-2 text-xs text-muted-foreground"> | ||
Photo by{" "} | ||
<span className="font-semibold text-foreground"> | ||
{artwork.artist} | ||
</span> | ||
</figcaption> | ||
</figure> | ||
))} | ||
</div> | ||
<ScrollBar orientation="horizontal" /> | ||
</ScrollArea> | ||
) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
Do we need the
flex-col
here? Can this be added via the consumer?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.
I believe this issue will be seen on all implementations of horizontal scroll bars, so I added it here since it seemed like bug. For a live reproduction of this issue, https://ui.shadcn.com/examples/music under
Listen Now
has a horizontal scroll bar that goes off screen when scrolling all the way to the right.