-
Notifications
You must be signed in to change notification settings - Fork 371
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[WIP] Spacing doc draft #103
base: main
Are you sure you want to change the base?
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,92 @@ | ||
# Spacing | ||
|
||
Careful spacing is key for the user to understand connections and hierarchies between elements, and for an interface to feel pleasant. | ||
|
||
## Scale | ||
|
||
Primer follows a base-8 scale, as it allows for significant flexibility when defining a variety of spacing values within an interface. | ||
|
||
`[list of spacing utilities]` | ||
|
||
For very small components where 8 pixel spacing is too large, you can use 4 pixels. | ||
|
||
## Responsive breakpoints | ||
|
||
You can define different spacing values for different breakpoints, so the interface can better adapt to the available space. | ||
|
||
`[Example: component with larger margin around it in large screen, vs smaller margin in small screen]` | ||
|
||
In code, margins can be defined per breakpoint, where different breakpoints have a different margin applied. | ||
|
||
`[Example: mb-sm-2 mb-md-3 mb-lg-4]` | ||
|
||
## Applying spacing | ||
|
||
The general rule when using Primer is to apply spacing in increments of 8 pixels, as provided by the spacing utilities. | ||
|
||
In some cases, for very small components and in denser areas of the UI, you can use 4 pixels. | ||
|
||
`[Example: text and icon button]` | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. TODO: image of text + icon button with redlines to indicate 4px space. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @ashygee will create this |
||
|
||
Primer components have inner spacing built-in, so in most cases you’ll only need to consider vertical spacing between components. | ||
|
||
Do/Don’t: Using custom values? | ||
yaili marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
yaili marked this conversation as resolved.
Show resolved
Hide resolved
|
||
## Relationships | ||
|
||
Elements that are close together are perceived as being related or part of the same group, while elements that are far apart from each other feel unrelated. | ||
|
||
`[Examples: cancel, save buttons; repo top nav buttons]` | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. TODO: Find an example of together and distant There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We can use the header and indicate repo name / social buttons / tabs as 3 different groups. |
||
|
||
Alignment | ||
yaili marked this conversation as resolved.
Show resolved
Hide resolved
|
||
- Do / Don’t | ||
yaili marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
## Hierarchy | ||
|
||
Do: Add more white space around components that are more important. | ||
|
||
`[Examples: titles]` | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. TODO: Add image of page titles. |
||
|
||
Note: Editorial content can have more generous spacing. | ||
|
||
`[Examples: first use cards, new features cards]` | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. TODO: example of editorial card. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. |
||
|
||
## Consistency | ||
|
||
Do: Apply the same spacing values to similar components. | ||
|
||
`[Example: all items in the sidebar have the same vertical distance]` | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. TODO: redline vertical spacing between repo homepage sidebar elements. |
||
|
||
## Density | ||
|
||
`[Examples: ]` | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @vdepizzol can you think of one example of high density components (or areas of a page) and one of low density? |
||
|
||
## Optical adjustments | ||
|
||
Icons | ||
|
||
Inline spacing | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Need examples for this type of adjustment @ashygee can you think of an example where inline spacing is important? Can we write down how we usually handle inset spacing? For example, is it usually the same vertically and horizontally? Or is vertical padding usually smaller than horizontal? |
||
|
||
## Common spacing values | ||
yaili marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
yaili marked this conversation as resolved.
Show resolved
Hide resolved
|
||
Small components usually have 8px between them. In some cases, for very small buttons, you can use 4px. | ||
|
||
`[Example: buttons side by side, labels, icon+text]` | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. TODO: image of buttons side by side, and of icon+text button, redlines with values. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Examples: side by side (separate) buttons it's 8px, and select field with save/delete button it's 4px (example in user settings) |
||
|
||
The most common value when stacking components vertically is 16px. | ||
|
||
`[Example: issue header above first comment, sidebar, stacked boxes]` | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. TODO: Image of stacked boxes at the bottom of pull requests comments tab. |
||
|
||
## Learn more about spacing | ||
If you’d like to read more about spacing in UI design, we recommend: | ||
yaili marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
- | ||
|
||
|
||
## Related | ||
|
||
- [Primer CSS - Support - Spacing](https://primer.style/css/support/spacing) | ||
- [Primer CSS - Utilities - Padding](https://primer.style/css/utilities/padding) | ||
- [Primer CSS - Utilities - Margin](https://primer.style/css/utilities/margin) | ||
- [Primer CSS - Utilities - Borders](https://primer.style/css/utilities/borders) | ||
- [Primer Primitives - Spacing](https://github.com/primer/primitives/blob/master/primitives/spacing.ts) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
TODO: Find example component
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You could reference the general spacing of the entire page? Padding/margin around most pages reduces at smaller screen sizes. I can try to think of some other examples, too.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
thanks @colinkeany that's a good idea for now, do you know a page that would be better to use as an example? maybe something with not too much going on? 🤔
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The issues page might be a good option? https://github.com/issues