Skip to content

Commit 82ccfe6

Browse files
authored
docs: add css layer names adr (#6030)
1 parent 3ed08b2 commit 82ccfe6

File tree

1 file changed

+83
-0
lines changed

1 file changed

+83
-0
lines changed
Lines changed: 83 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,83 @@
1+
# CSS Layer Names
2+
3+
## Status
4+
5+
| Stage | Status |
6+
| -------- | ----------- |
7+
| Approved | 🚧 |
8+
| Adopted | <!----> |
9+
10+
## Context
11+
12+
As Primer begins making use of CSS Layers, we need to define the named groups
13+
and order of the layers that we create. This will help to ensure a consistent
14+
ordering of layers and make sure that our naming is consistent across libraries.
15+
16+
We have several areas that may be helpful to define explicit layers for:
17+
18+
- Primitives
19+
- Octicons
20+
- Components
21+
- Resets
22+
- Utilities
23+
- Product
24+
25+
This ADR will determine the naming convention for CSS Layers and the order in
26+
which they should be applied.
27+
28+
## Decision
29+
30+
Below is the list of CSS layers that we will use in Primer. They appear in the
31+
order in which they should be applied.
32+
33+
- `base`: base styles that are applied to the document and the root element. This includes things like resets, typography, and
34+
global styles.
35+
- `theme`: styles that are applied for theming. This layer includes `@primer/primitives`
36+
- `icons`: styles that are applied to octicons
37+
- `components`: styles that are applied to components
38+
- `utilities`: an optional layer for utility classes in order to take precedence over earlier styles
39+
40+
All layers should exist within the `primer` namespace. For example:
41+
42+
```css
43+
@layer primer.base {
44+
/* ... */
45+
}
46+
47+
@layer primer.components.Button {
48+
/* ... */
49+
}
50+
```
51+
52+
Naming for these layers must use `camelCase`. The only exception would be for
53+
the names of components which must use `PascalCase`.
54+
55+
### Where should the order of CSS layers be defined
56+
57+
The definition of CSS layers ordering is:
58+
59+
```css
60+
@layer primer.base, primer.theme, primer.icons, primer.components, primer.utilities;
61+
```
62+
63+
This file lives in `layer.css` which is imported by each entrypoint that `@primer/react` provides.
64+
65+
### Impact
66+
67+
This change will impact the following libraries:
68+
69+
- primer/css: styles in this library should be wrapped in either the utilities
70+
or icons layer.
71+
- primer/primitives: styles in this library should be wrapped in the theme layer
72+
- primer/octicons: styles in this library should be wrapped in the icons
73+
layer
74+
- primer/react: styles in this library should be wrapped in the components layer
75+
- primer/view_components: styles in this library should be wrapped in the components
76+
layer
77+
78+
## Unresolved questions
79+
80+
## Links & Resources
81+
82+
- [Tailwind CSS v4 Integration for Material UI](https://mui.com/material-ui/integrations/tailwindcss/tailwindcss-v4/)
83+
- [Mantine CSS Layers](https://mantine.dev/styles/mantine-styles/#css-layers)

0 commit comments

Comments
 (0)