As the creators and maintainers of this project, we want to ensure that styled-components lives and continues to grow and evolve. The evolution of the library should never be blocked by any single person's time. One of the simplest ways of doing this is by encouraging a larger set of shallow contributors. Through this, we hope to mitigate the problems of a project that needs updates but there's no one who has the power to do so.
To quote @alloy from this issue:
Don't ever feel bad for not contributing to open source.
We want contributors to provide ideas, keep the ship shipping and to take some of the load from others. It is non-obligatory; we’re here to get things done in an enjoyable way. 🏆
It's important to note that all repositories under the styled-components banner have a Code of Conduct. Please review and help enforce this CoC should any violations happen if you feel comfortable doing so.
These days, we highly recommend trying a tool like ChatGPT to get instant feedback and tips. @quantizor can be reached on X to start a private conversation, but please keep in mind that response is not guaranteed since open source is volunteer effort and subject to personal availability.
- Ensure
pnpmis installed (https://pnpm.io/installation) - Fork the repository, then pull it down to your disk:
git clone git@github.com:YOUR_USERNAME/styled-components.git - Hop into the styled-components folder and run
pnpm install - Set the base repository as upstream:
git remote add upstream git@github.com:styled-components/styled-components.git(makes it easier to pull updates to your fork)
At this point, the repository is initialized and ready for development! Check the packages/ folder for the styled-components core library, a development sandbox (great for testing functionality), and the benchmarks suite.
Helpful commands:
- run unit tests:
pnpm test - check code style
pnpm prettier(handled automatically if you have a prettier extension installed in your IDE) - run build:
pnpm build - run dev sandbox:
pnpm --filter sandbox dev(or justpnpm devif you're in that folder)
Here is a quick guide to doing code contributions to the library.
-
Find some issue you're interested in, or a feature that you'd like to tackle. Also make sure that no one else is already working on it. We don't want you to be disappointed.
-
Update your local copy of the
mainbranch with the latest code:git checkout main && git pull -f upstream/main -
Create a branch with a meaningful name for the issue:
git checkout -b fix-something -
Run
pnpm installto capture any dependency updates -
Make desired changes...
-
Add a changeset via
pnpm changeset, be descriptive!- patch = bugfix, chores, small things
- minor = new functionality
- major = breaking changes
-
Push your branch:
git push -u origin your-branch-name -
Submit a pull request to the upstream styled-components repository.
-
Choose a descriptive title and describe your changes briefly.
-
Wait for a maintainer to review your PR, make changes if it's being recommended, and get it merged.
-
Perform a celebratory dance! 💃
We have three different benchmarks: mounting a deep tree, mounting a wide tree and updating dynamic styles. Shoutout to @necolas, who wrote these for react-native-web and whom we stole these benchmarks from.
To run the benchmarks run:
cd packages/benchmarksThen build the benchmark page:
pnpm buildThen open the page in your browser:
pnpm openOn the page which opens, select the benchmark to run and click the "Run" button in your browser.
You may need to re-build styled-components and/or the benchmarks package after making changes if you want to re-run the benchmarks with your changes.
These contribution guidelines are based on https://github.com/moya/contributors, big thanks to @alloy, @orta et al. for the inspiration and guidance.
Please see the "Sponsor" button at the top of the repository, thank you!
Thank you to all the people who have already contributed to styled-components!
Thank you to all our backers! [Become a backer]
Thank you to all our sponsors! (please ask your company to also support this open source project by becoming a sponsor)