|
1 | 1 | # Shape |
2 | 2 |
|
| 3 | +> For the complete current token reference including Sana Canvas values, see [v4.4 Token Reference](./v4.4-token-reference.md). |
| 4 | +
|
3 | 5 | ## Usage Guidance |
4 | 6 |
|
5 | 7 | Shape tokens define border radius values for UI elements. Apply them to create consistent rounded corners across similar components. |
6 | 8 |
|
7 | | -## Shape Tokens |
8 | | - |
9 | | -Shape tokens are aliased to base `size` tokens to define border radius. Each token corresponds to a specific use case and component type. |
10 | | - |
11 | | -[View our shape tokens](https://workday.github.io/canvas-tokens/?path=/docs/docs-system-tokens-shape--docs) |
| 9 | +Use t-shirt size names (`sm`, `md`, `lg`, …). The old scalar scale (`x1`, `x2`, `x4`, `x6`, `zero`, `half`, `round`) is deprecated. |
12 | 10 |
|
13 | 11 | ## Shape Tokens |
14 | 12 |
|
15 | | -| Token | Value | Size (px) | Usage | |
16 | | -|------------------|-----------|-----------|------------------------------------------| |
17 | | -| `shape.none` | `size.0` | `0px` | No border radius | |
18 | | -| `shape.sm` | `size.50` | `4px` | Small border radius for compact components| |
19 | | -| `shape.md` | `size.100`| `8px` | Medium border radius for form components | |
20 | | -| `shape.lg` | `size.150`| `12px` | Large border radius for content editors | |
21 | | -| `shape.xl` | `size.200`| `16px` | Extra large for smaller cards | |
22 | | -| `shape.xxl` | `size.300`| `24px` | Extra extra large for cards | |
23 | | -| `shape.xxxl` | `size.400`| `32px` | Maximum for large elevated containers | |
24 | | -| `shape.full` | `size.75 * 100` | `999px` | Full rounding for high-visibility components | |
25 | | - |
26 | | -### None |
27 | | - |
28 | | -Value: `size.0` |
29 | | - |
30 | | -No border radius. Use for full-width and background containers, fixed navigation containers such as headers and side-panels. |
31 | | - |
32 | | -### Small |
33 | | - |
34 | | -Value: `size.50` |
35 | | - |
36 | | -Small border radius for compact components. Used for pills, status indicators, and checkboxes. |
37 | | - |
38 | | -### Medium |
39 | | - |
40 | | -Value: `size.100` |
41 | | - |
42 | | -Medium border radius for form components and notifications. Used for inputs, toasts, tooltips, and snackbars. |
43 | | - |
44 | | -### Large |
45 | | - |
46 | | -Value: `size.150` |
| 13 | +| Token | Default | Sana | Usage | |
| 14 | +|---|---|---|---| |
| 15 | +| `shape.none` | 0 | same | Full-width containers, headers, side panels | |
| 16 | +| `shape.xs` | — | 4px | Sana-only — compact rounding | |
| 17 | +| `shape.sm` | 4px | 6px | Pills, status indicators, checkboxes | |
| 18 | +| `shape.md` | 8px | same | Inputs, toasts, tooltips, snackbars | |
| 19 | +| `shape.lg` | 12px | same | Rich text editors | |
| 20 | +| `shape.xl` | 16px | same | Compact cards | |
| 21 | +| `shape.xxl` | 24px | 20px | Cards, list items | |
| 22 | +| `shape.xxxl` | 32px | 28px | Modals, dialogs, bottom sheets | |
| 23 | +| `shape.full` | 999px | same | Buttons, badges, avatars — fully rounded | |
47 | 24 |
|
48 | | -Large border radius for content editors. Used for rich text editors. |
| 25 | +Under `data-theme="sana-canvas"`, shape values change automatically. Write `system.shape.*` — do not use `system.sana.shape.*`. |
49 | 26 |
|
50 | | -### Extra Large |
51 | | - |
52 | | -Value: `size.200` |
53 | | - |
54 | | -Extra large border radius for smaller cards and containers. Used for compact card components and smaller content containers. |
55 | | - |
56 | | -### Extra Extra Large |
57 | | - |
58 | | -Value: `size.300` |
59 | | - |
60 | | -Extra extra large border radius for cards and list items. Used for card components and large content containers. |
61 | | - |
62 | | -### Extra Extra Extra Large |
63 | | - |
64 | | -Value: `size.400` |
65 | | - |
66 | | -Maximum border radius for large elevated containers. Used for dialogs, modals, bottom sheets, and other elevated parent containers with substantial content. |
67 | | - |
68 | | -### Full |
69 | | - |
70 | | -Value: `size.75 * 100` |
71 | | - |
72 | | -Full rounding for high-visibility components intended to draw attention. Used for buttons, badges, status indicators, essential inputs, and border containers (not cards). |
| 27 | +[View our shape tokens](https://workday.github.io/canvas-tokens/?path=/docs/docs-system-tokens-shape--docs) |
73 | 28 |
|
74 | 29 | ## Using our Shapes |
75 | 30 |
|
76 | 31 | **Do:** |
77 | 32 |
|
78 | | -- Apply the same border radius value to all corners of an element. This ensures the shape doesn't get distorted. |
79 | | -- Choose shape tokens based on component type and use case. Follow the recommended usage for each token size. |
| 33 | +- Apply the same border radius value to all corners of an element. |
| 34 | +- Choose shape tokens based on component type and use case. |
80 | 35 |
|
81 | | -**Dont:** |
| 36 | +**Don't:** |
82 | 37 |
|
83 | | -- Don't combine different border radius values on the same element. |
84 | | -- Don't use different values for different corners unless specifically required. |
| 38 | +- Combine different border radius values on the same element. |
| 39 | +- Use deprecated scalar tokens (`shape.x1`, `shape.x2`, `shape.round`, `shape.zero`). |
85 | 40 |
|
86 | 41 | ## Web Examples |
87 | 42 |
|
88 | 43 | ### Javascript / Typescript |
89 | 44 |
|
90 | 45 | ```tsx |
91 | | -// styles.ts |
| 46 | +import {createStyles} from '@workday/canvas-kit-styling'; |
92 | 47 | import {system} from '@workday/canvas-tokens-web'; |
93 | 48 |
|
94 | | -const styles = { |
95 | | - borderRadius: `var(${system.shape.xxl})`, |
96 | | -}; |
| 49 | +const cardStyles = createStyles({ |
| 50 | + borderRadius: system.shape.xxl, |
| 51 | +}); |
97 | 52 | ``` |
98 | 53 |
|
| 54 | +`createStyles` resolves token names to `var(--cnvs-…)` automatically. Outside `createStyles`, wrap tokens with `cssVar()` or a `` `var(${token})` `` template literal. |
| 55 | + |
99 | 56 | ### CSS |
100 | 57 |
|
101 | 58 | ```css |
102 | | -// styles.css |
103 | 59 | @import '@workday/canvas-tokens-web/css/system/_variables.css'; |
104 | 60 | .card { |
105 | 61 | border-radius: var(--cnvs-sys-shape-xxl); |
106 | 62 | } |
107 | 63 | ``` |
108 | | - |
109 | | - |
0 commit comments