Contributing to Shadcn UI

Learn how to contribute to the shadcn/ui codebase

Project Source Code

Get the project source code below, and follow along with the lesson material.

Download Project Source Code

To set up the project on your local machine, please follow the directions provided in the README.md file. If you run into any issues with running the project source code, then feel free to reach out to the author in the course's Discord channel.

Previous LessonSetup shadcn/ui Development EnvironmentNext LessonExercise - Contribute to shadcn/ui

This lesson preview is part of the Sleek Next.JS Applications with shadcn/ui course and can be unlocked immediately with a \newline Pro subscription or a single-time purchase. Already have access to this course? Log in here.

This video is available to students only
Unlock This Course

Get unlimited access to Sleek Next.JS Applications with shadcn/ui, plus 70+ \newline books, guides and courses with the \newline Pro subscription.

Thumbnail for the \newline course Sleek Next.JS Applications with shadcn/ui

In the previous lesson, you've learned about the ShadCNUI codebase and how to set up the development environment. In this lesson, you will learn how to contribute to the ShadCNUI codebase. The best places to find contribution opportunities are GitHub issues and GitHub discussions. Contributions can be anything from fixing a type of documentation to adding a new feature to the library. The first thing is issues. Issues are a great place to start. You can look for things to fix or to clarify. Navigate to the repository and click on the Issues tab. You will see a list of issues that you can filter by labels, projects and milestones. For example, you can filter by the bug label. This is everything that is not working. Sometimes you can help clarify. So a good first contribution could be just help people. Or even fix the bug that you are describing. A good first contribution could be adding labels to issues that doesn't have them yet. Or helping clarify the issues that require investigation. Issues should mostly include bugs or problems that needs to be fixed. Feature requests are belonging discussions. If someone else is already working on issues, it's a good idea to comment before you start working on it. Another thing to note is that sometimes people create issues that are not actually an issue. They might be asking questions or requesting a feature. It can be very helpful to help maintainers and help clarifying if it's an issue , a bug or belong to something like Stack Overflow. Another thing to remember is that ShadCNUI is built on top of Radix UI and tail wind CSS as you've learned about in the first module. It's possible that the actual issue in ShadCNUI is the bug in one of those libraries. And ShadCNUI will have little control over the example. This issue for example is a good idea. Here's an example of a good idea that you may be able to solve. In iPhone 15 Pro with Safari, when toggling the drawer, it flashes back and open on close. You can try and fix that. GitHub discussions are another place to look for things that you can help library maintainers with. Navigate to their repositories and click on the Discussions tab. They are divided into categories. Discussions can include feature requests, questions and ideas for the libraries . You can see it here. They are a great place to engage with the community and even get ideas for pull requests. Here is an example of a feature idea for the library that I'm seeing like a few times already. Adding a color picker. You can comment on the discussion, ask for more details or even start working on the feature. These are all just examples of ideas and discussions in the ShadCNUI repository . I really encourage you to explore the repository and find something that interests you. Let's make a pull request for the color picker. We can add a color picker component that make a pull request. It doesn't mean it will be merged, but it's a good example of how to make a pull request. Please do not go and add now a color picker pull request to ShadCNUI without first discussing it with the maintainers. This is just an example of what making a pull request might look like. You should already have the repository for and clone to your local machine. And if you don't, please refer to the previous lesson. The first step would be to create a new branch for the color picker feature. Open your terminal and navigate to the UI folder. Then run the git checkout command with dash b and color picker arguments. We now switch to a new branch color picker. Now install the react colorful package. It's a simple color picker for the app. And let's create a picker component. Open the ShadCNUI source code and create a new component. It require adding the component source and the component example. For both sides, we need to create a new files in apps /www/registre. And then inside the default folder, go to UI and create a new color picker T65. We're going to import the pipeta from Lucid React, which is the icon. Then we're going to import the hex color picker from React Colorful. And import the popover content and popover trigger components. From the registry default UI popover. Then let's select a list of default colors that we want to allow users to select. And export const color picker, which is the actual function. It will receive a color, which is a string, and a non-change function. As pops, it will receive the color and the on-change properties. The color is a string and the on-change function is a function that returns void and receive color as an argument. Then immediately return a div with a class name of flex item center in GapFord. And wrap everything in a popover. Then for the popover trigger, we'll render a simple color component that receives a color. And a wrapper property. The color component will be imported from the React Colorful component. Let's build the color component. Export const color. She's a color preview. Receives a color and on click. And whether it's a wrapper or not. So the wrapper is a Boolean. And the color is a string. And the on-click is a function that returns nothing and receives nothing. If we need to wrap everything, if it's a wrapper, then we want to return a div with a class name of flex size 8, item center and justify center, round the empty, and give it a bit of a border. You'll see in a second why we need the wrapper component type. Add an on-click handler. She's simply the on-click prop. And then render the color inside. It's a simple div with the size 4 class name and a rounded full class name as well. Then we want to apply an inline style with the background set to the color past as a prop. If we don't need it to be a wrapper, we can simply render the color, make its size 4, round it full, and scale it a bit when the user hover the component. Then for style apply the background, then apply the background to the color from the props, and the on-click function. And simply close the div. We now have the color component ready. On-click should be optional. Now render the popover content. Give it a class name of flex, height 14, item center, justify center, and a minor padding center, and a minor padding on the side and zero padding on the vertical. Then render a div that will show the default colors to the user. Loop through the default colors object. And then for each color, render the color component that we've created. The key will be the color, and the color will be the color. And on-click, call the on-change function. Don't forget to close it. And then we want to add another div, which will have another popover. It's a popover inside the popover. And the trigger will be the pipeta icon. Add a bit of a border and a bit of a padding, and render the pipeta icon. Inside the popover content, we want to render the hex color figure. On-change, we will call the on-change function. And for the color property, we'll simply pass the color. That's it, our component is ready. We now can copy and paste it into the New York folder inside UI, color-peaker. Don't forget to replace the popover to be from the New York style. The next step would be to add those to the registry. We've seen the registry before. Go to the UI registry. And add a color-peaker component. Everything here is ordered by the alphabet. So give it a name, color-peaker. A type of components UI. And then the dependencies are none. But the registry dependencies are the popover that we used. Then the dependencies are the React Color Full Package. The files are the UI/color-peaker.t6. And the registry dependencies are the popover that we've used. Let's add it to the examples registry as well. The color will call it color-peaker demo. The type would be components example. The registry dependencies popover. And the files are the example color-peaker demo. We don't need to add demos. So in both the New York and the UI, example folder, let's add the color-peaker demo. Copy and paste this. It's fairly simple. We're importing the color-peaker and use state-phone we add. We're calling the state with a default color and passing both props to the color-peaker component. Do the same in the default example registry. And the next step would be to add the color-peaker to the docs. Open the apps / www/content and components. And add the color-peaker.mdex file. Now let's add the color-peaker component, the documentation file. If you look at the other component documentation, you can see the title and description properties on the markdown definition. So let's copy and paste that. We can remove the links. In the description, we can write a color-peaker component. And the title would be color-peaker. Then we can render the component preview that we've seen earlier with the color -peaker demo value. We can add an installation. And we can copy from the collapsible implementation. We'd want to change the CLI command to add color-peaker. And in the manual, we want to include the manual steps. You have all the steps in the course text below, but we want to install React Colorful. And then simply copy and paste the component source that will be rendered based on the component source component. Now let's show the usage. The usage is simply importing the color-peaker. And rendering it. Now we navigate to app/www/config/docs.ts. And we need to add the components to the cybernet under the components. Alright. Before the combo box component, add a title color-peaker with an hf2docs-comp onents-color-peaker. And items equal to an empty array. Then don't forget to add the command. And then let's run the build command, Navigator-Terminal. And run pnpm, run build.registry. Go to the UI.ds where I forgot to add a comma. And we run the command. The registry was built successfully. And run pnpm-fielder = www.dev. Navigator-localhost with your port and go to docs. Navigator-localhost for me is 30003. Navigator-d docs. And locate the color-peaker. We can now see the color-peaker component. When I click on it, I can switch the color-peaker. And I can even pick a color-peaker from the hex color-peaker of React-color- foot. I can see the installation. And the usage documentation. I have a double installation. A double installation title that we can remove. Now it's time to commit and push changes to your fault. Shad senior I conduct contributing guidelines. Defines a committed structure for the project. It looks like this. A category, then scope all module, and a message. The categories are feature, which is a feature, a fix, refactor, docs, build, test, CI, and short. For new components, it's recommended to use the feature category. So we want to add everything that we've changed. And then commit with a feature color-peaker. Add color-peaker component. And then we can push two-hour branch. Remember, this is only a fault. I want to say something very important. Please do not create a pull request without discussing it with maintainers first. Please do not create a pull request with the course code for the color-peaker component, as it's just a demonstration of how the process of developing for the Shad senior I project looks like. And don't create a pull request with the commit message above. This is simply an example of the process of contributing to the library. If you actually want to contribute to Shad senior I, please follow the contributing guidelines and discuss your ideas with the maintainers first. That's it for this lesson. In the next lesson you will have an exercise contributing to Shad senior I.