Skip to content

Commit 3249768

Browse files
joshblacklesliecdubsCopilotfrancinelucca
authored
docs(adr): add adr for @primer/styled-react (#6722)
Co-authored-by: Leslie Cohn-Wein <[email protected]> Co-authored-by: Copilot <[email protected]> Co-authored-by: Marie Lucca <[email protected]> Co-authored-by: Marie Lucca <[email protected]>
1 parent 5c30443 commit 3249768

File tree

1 file changed

+58
-0
lines changed

1 file changed

+58
-0
lines changed
Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
# [ADR] Add supporting package for styled components
2+
3+
📆 Date: 2025-09-04
4+
5+
## Status
6+
7+
| Stage | State |
8+
| -------------- | ----------------------------------------------------------------------------------------------------- |
9+
| Status | Accepted ✅ <!-- Proposed ❓ OR Accepted ✅ OR Superseded by [LINK](https://) ⚠️ OR Deprecated ⛔ --> |
10+
| Implementation | Adopted ✅ <!-- Not planned ⛔ OR Adoption awaiting in [LINK](https://) ⏸️ OR Adopted ✅ --> |
11+
12+
## Context
13+
14+
<!-- Provide background information and the reasons for this decision. What are the business, technical, or other drivers that motivated this decision? -->
15+
16+
We would like to remove support for styled-components from Primer React in order to [advance CSS Modules](https://github.com/primer/react/blob/main/contributor-docs/adrs/adr-016-css.md#decisions) as a performant styling architecture for the library.
17+
However, there is still existing usage of styled-components downstream that is
18+
unlikely for us to be able to migrate. As a result, we would like to explore
19+
adding a supporting package to Primer React that will allow components to work
20+
with styled-components while providing the ability for us to remove it from
21+
`@primer/react` directly in favor of CSS Modules. This should encourage Primer React consumers to [fall into the "pit of success"](https://blog.codinghorror.com/falling-into-the-pit-of-success/) while allowing a reasonable migration period.
22+
23+
## Decision
24+
25+
<!-- Clearly state the architectural decision that has been made. This includes details about the chosen solution. -->
26+
27+
We will create a new package called `@primer/styled-react` to mirror the
28+
existing `@primer/styled-octicons` package. This package will re-export
29+
components from `@primer/react` that still have `sx` usage downstream in order
30+
to provide compatibility with `styled-components` and the latest version of
31+
`@primer/react`. This package will allow teams to use the latest version of
32+
`@primer/react` without having to fully migrate from `sx`.
33+
34+
This package will stay at a pre-1.0 version. Over time, we will remove
35+
components from `@primer/styled-react` when their `sx` usage across key GitHub repos goes to zero.
36+
37+
This package and the components within will be deprecated by default to
38+
encourage migrating to using CSS Modules over `styled-components`.
39+
40+
## Consequences
41+
42+
<!-- What are the consequences of this decision? Include both positive and negative outcomes. What trade-offs come with this decision? -->
43+
44+
With this decision, we will end up publishing two packages from `primer/react`
45+
and associated workflows will need to be updated to accommodate this change. In
46+
addition, we are expanding the scope of packages from Primer that teams may
47+
interact with. Finally, providing support in this way may lead to prolonged
48+
usage of `styled-components` since we are not forcing anyone to migrate to use
49+
the latest version of `@primer/react`.
50+
51+
## Alternatives
52+
53+
<!-- Describe other options that were considered and why they were not chosen. This helps provide context and justification for the decision. -->
54+
55+
One alternative to this path is to attempt to migrate teams off of
56+
`styled-components` and `sx` usage before making this change. However, with our
57+
recent attempts to do this CSS Modules refactor, it would be helpful to decouple
58+
migration efforts from the library as they can take a while to land.

0 commit comments

Comments
 (0)