-
Notifications
You must be signed in to change notification settings - Fork 101
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
19 changed files
with
309 additions
and
27 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,92 @@ | ||
--- | ||
title: Layout Spacing | ||
category: Guides | ||
order: 8 | ||
--- | ||
|
||
# Layout Spacing | ||
|
||
Our design system provides a set of spacing tokens for consistent layouts and components. Some tokens share values but should be used semantically. For instance, while both `space12` and `buttons` are 12px, `buttons` should be used for spacing between buttons. | ||
|
||
## Tokens | ||
|
||
| Key | Value | | ||
|--------------------|--------| | ||
| space0 | 0px | | ||
| space2 | 2px | | ||
| space4 | 4px | | ||
| space8 | 8px | | ||
| space12 | 12px | | ||
| space16 | 16px | | ||
| space24 | 24px | | ||
| space36 | 36px | | ||
| space48 | 48px | | ||
| space60 | 60px | | ||
| sections | 36px | | ||
| sectionElements | 24px | | ||
| trayElements | 24px | | ||
| modalElements | 24px | | ||
| moduleElements | 16px | | ||
| paddingCardLarge | 24px | | ||
| paddingCardMedium | 16px | | ||
| paddingCardSmall | 12px | | ||
| selects | 16px | | ||
| textAreas | 16px | | ||
| inputFields | 16px | | ||
| checkboxes | 16px | | ||
| radios | 16px | | ||
| toggles | 16px | | ||
| buttons | 12px | | ||
| tags | 12px | | ||
| statusIndicators | 12px | | ||
| dataPoints | 12px | | ||
|
||
## Applying Spacing | ||
|
||
There are three main ways to apply spacing in our component library: | ||
|
||
### 1. Using the `margin` Prop | ||
|
||
Most components in the library support a `margin` prop that works similarly to the CSS margin property. You can specify a single value or fine-tune individual margins (e.g., top, right, bottom, left). | ||
|
||
```ts | ||
--- | ||
type: example | ||
--- | ||
<div> | ||
<Button margin="0 buttons 0 0">Button 1</Button> | ||
<Button>Button 2</Button> | ||
</div> | ||
``` | ||
|
||
### 2. Using a Container Component with the `gap` Prop | ||
|
||
For layouts, container components like `Flex` and `Grid` can be used with the gap prop to manage spacing between child elements. | ||
|
||
```ts | ||
--- | ||
type: example | ||
--- | ||
<Flex gap="buttons"> | ||
<Button>Button 1</Button> | ||
<Button>Button 2</Button> | ||
</Flex> | ||
``` | ||
|
||
### 3. Importing Values from the Theme | ||
|
||
If you need to directly reference spacing values, you can import them from the theme. This approach is useful for applying spacing in inline styles or custom components. | ||
|
||
```ts | ||
--- | ||
type: code | ||
--- | ||
// import the canvas theme | ||
import canvas from '@instructure/ui-themes' | ||
|
||
// use spacing values | ||
<div style={{display: 'flex', gap: canvas.spacing.buttons}}> | ||
<button>Button 1</button> | ||
<button>Button 2</button> | ||
</div> | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
/* | ||
* The MIT License (MIT) | ||
* | ||
* Copyright (c) 2015 - present Instructure, Inc. | ||
* | ||
* Permission is hereby granted, free of charge, to any person obtaining a copy | ||
* of this software and associated documentation files (the "Software"), to deal | ||
* in the Software without restriction, including without limitation the rights | ||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | ||
* copies of the Software, and to permit persons to whom the Software is | ||
* furnished to do so, subject to the following conditions: | ||
* | ||
* The above copyright notice and this permission notice shall be included in all | ||
* copies or substantial portions of the Software. | ||
* | ||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | ||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | ||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE | ||
* SOFTWARE. | ||
*/ | ||
|
||
import type { Theme } from '@instructure/ui-themes' | ||
|
||
const generateComponentTheme = (theme: Theme): any => { | ||
const { spacing } = theme | ||
|
||
return { spacing } | ||
} | ||
|
||
export default generateComponentTheme |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.