Shadcn-ui codebase analysis: How is the hero section built on ui.shadcn.com website?
I wanted to find out how the hero section is developed on ui.shadcn.com, so I looked at its source code. Because shadcn-ui is built using app router, the files I was interested in were Layout.tsx and page.tsx.
In this article, we will find out the below items:
Where is the code related to the hero section shown in the image below
2. Hero section code snippet.
3. PageHeader component.
Want to learn how to build shadcn-ui/ui from scratch?Sovle challengesto build shadcn-ui/ui from scratch. If you are stuck or need help?there is a solution. Check outbuild-from-scratchand give it a star if you like it.
<PageHeader> <Announcement /> <PageHeaderHeading>Build your component library</PageHeaderHeading> <PageHeaderDescription> Beautifully designed components that you can copy and paste into your apps. Accessible. Customizable. Open Source. </PageHeaderDescription> <PageActions> <Link href="/docs" className={cn(buttonVariants())}> Get Started </Link> <Link target="_blank" rel="noreferrer" href={siteConfig.links.github} className={cn(buttonVariants({ variant: "outline" }))} > <Icons.gitHub className="mr-2 h-4 w-4" /> GitHub </Link> </PageActions></PageHeader>
PageHeader, Announcement, PageHeaderHeading, PageHeaderDescription, PageActions are imported as shown below
import { Announcement } from "@/components/announcement"import { PageActions, PageHeader, PageHeaderDescription, PageHeaderHeading,} from "@/components/page-header"
Shadcn-ui website’s hero section code is found in page.tsx and this code uses page-header.tsx components such as PageHeaderHeading, PageHeaderDescription, PageHeaderActions etc.,
Hey, my name is Ramu Narasinga. I study large open-source projects and create content about their codebase architecture and best practices, sharing it through articles, videos.