@carbon/element-styles 0.2.0-rc.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (78) hide show
  1. package/LICENSE +201 -0
  2. package/README.md +281 -0
  3. package/package.json +40 -0
  4. package/src/_config.scss +8 -0
  5. package/src/elements/_heading/index.scss +27 -0
  6. package/src/elements/_input/index.scss +92 -0
  7. package/src/elements/_labelled-input/index.scss +143 -0
  8. package/src/elements/_layer/index.scss +78 -0
  9. package/src/elements/abbreviation/index.scss +31 -0
  10. package/src/elements/address/index.scss +31 -0
  11. package/src/elements/anchor/index.scss +50 -0
  12. package/src/elements/block-quotation/index.scss +63 -0
  13. package/src/elements/body/index.scss +30 -0
  14. package/src/elements/bold-text/index.scss +27 -0
  15. package/src/elements/button/index.scss +235 -0
  16. package/src/elements/checkbox/index.scss +76 -0
  17. package/src/elements/code/index.scss +34 -0
  18. package/src/elements/combo-box/index.scss +68 -0
  19. package/src/elements/date-input/index.scss +47 -0
  20. package/src/elements/date-time-input/index.scss +47 -0
  21. package/src/elements/deleted-text/index.scss +33 -0
  22. package/src/elements/description-list/index.scss +42 -0
  23. package/src/elements/details/index.scss +85 -0
  24. package/src/elements/dialog/index.scss +211 -0
  25. package/src/elements/fieldset/index.scss +41 -0
  26. package/src/elements/file-input/index.scss +84 -0
  27. package/src/elements/footer/index.scss +34 -0
  28. package/src/elements/header-navigation/index.scss +125 -0
  29. package/src/elements/heading-level-1/index.scss +30 -0
  30. package/src/elements/heading-level-2/index.scss +30 -0
  31. package/src/elements/heading-level-3/index.scss +30 -0
  32. package/src/elements/heading-level-4/index.scss +30 -0
  33. package/src/elements/heading-level-5/index.scss +30 -0
  34. package/src/elements/heading-level-6/index.scss +30 -0
  35. package/src/elements/horizontal-rule/index.scss +41 -0
  36. package/src/elements/inline-loading/index.scss +70 -0
  37. package/src/elements/inline-quotation/index.scss +28 -0
  38. package/src/elements/inserted-text/index.scss +34 -0
  39. package/src/elements/italic-text/index.scss +27 -0
  40. package/src/elements/keyboard-input/index.scss +34 -0
  41. package/src/elements/label/index.scss +52 -0
  42. package/src/elements/main/index.scss +32 -0
  43. package/src/elements/marked-text/index.scss +33 -0
  44. package/src/elements/menu/index.scss +106 -0
  45. package/src/elements/number-input/index.scss +37 -0
  46. package/src/elements/ordered-list/index.scss +50 -0
  47. package/src/elements/paragraph/index.scss +30 -0
  48. package/src/elements/password-input/index.scss +38 -0
  49. package/src/elements/popover/index.scss +71 -0
  50. package/src/elements/preformatted/index.scss +43 -0
  51. package/src/elements/progress-bar/index.scss +86 -0
  52. package/src/elements/radio-button/index.scss +67 -0
  53. package/src/elements/range-input/index.scss +76 -0
  54. package/src/elements/search-input/index.scss +47 -0
  55. package/src/elements/select/index.scss +71 -0
  56. package/src/elements/side-navigation/index.scss +141 -0
  57. package/src/elements/small-text/index.scss +31 -0
  58. package/src/elements/table/index.scss +131 -0
  59. package/src/elements/tabs/index.scss +214 -0
  60. package/src/elements/text-area/index.scss +43 -0
  61. package/src/elements/text-input/index.scss +40 -0
  62. package/src/elements/tile/index.scss +72 -0
  63. package/src/elements/time-input/index.scss +47 -0
  64. package/src/elements/toggle/index.scss +106 -0
  65. package/src/elements/tooltip/index.scss +44 -0
  66. package/src/elements/tree-view/index.scss +127 -0
  67. package/src/elements/unordered-list/index.scss +46 -0
  68. package/src/index.scss +10 -0
  69. package/src/layout/_density.scss +27 -0
  70. package/src/layout/_mode.scss +349 -0
  71. package/src/layout/_size.scss +54 -0
  72. package/src/layout/index.scss +10 -0
  73. package/src/prebuilt/editorial.scss +94 -0
  74. package/src/prebuilt/expressive.scss +153 -0
  75. package/src/prebuilt/productive.scss +153 -0
  76. package/src/utilities/_carbon.scss +96 -0
  77. package/src/utilities/_icons.scss +111 -0
  78. package/src/utilities/_tokens.scss +35 -0
@@ -0,0 +1,43 @@
1
+ /**
2
+ * Copyright IBM Corp. 2026
3
+ *
4
+ * This source code is licensed under the Apache-2.0 license found in the
5
+ * LICENSE file in the root directory of this source tree.
6
+ */
7
+
8
+ @use 'sass:map';
9
+
10
+ @use '../_labelled-input';
11
+
12
+ @use '../../layout';
13
+
14
+ $config: () !default;
15
+
16
+ $-default-config: (
17
+ selector: 'label:has(textarea)',
18
+ );
19
+
20
+ /// @group text-area
21
+ /// @param {Map} config [()]
22
+ /// @param {Selector} config.selector ['label:has(textarea)']
23
+ @mixin styles($config: $config) {
24
+ $props: map.deep-merge($-default-config, $config);
25
+
26
+ #{map.get($props, 'selector')} {
27
+ @include labelled-input.styles((
28
+ label: (
29
+ selector: '&',
30
+ axis: 'block',
31
+ ),
32
+ input: (
33
+ selector: 'textarea',
34
+ ),
35
+ input-invalid-slot: 'after',
36
+ ));
37
+
38
+ & textarea {
39
+ min-block-size: calc(layout.$size--padding-block-start + 2lh + layout.$size--padding-block-end);
40
+ resize: vertical;
41
+ }
42
+ }
43
+ }
@@ -0,0 +1,40 @@
1
+ /**
2
+ * Copyright IBM Corp. 2026
3
+ *
4
+ * This source code is licensed under the Apache-2.0 license found in the
5
+ * LICENSE file in the root directory of this source tree.
6
+ */
7
+
8
+ @use 'sass:map';
9
+
10
+ @use '../_labelled-input';
11
+
12
+ @use '../../layout';
13
+
14
+ $config: () !default;
15
+
16
+ $-default-config: (
17
+ selector: 'label:has(input[type="text"])',
18
+ axis: 'block',
19
+ );
20
+
21
+ /// @group text-input
22
+ /// @param {Map} config [()]
23
+ /// @param {Selector} config.selector ['label:has(input[type="text"])']
24
+ /// @param {'block' | 'axis'} config.axis ['block']
25
+ @mixin styles($config: $config) {
26
+ $props: map.deep-merge($-default-config, $config);
27
+
28
+ #{map.get($props, 'selector')} {
29
+ @include labelled-input.styles((
30
+ label: (
31
+ selector: '&',
32
+ axis: map.get($props, 'axis'),
33
+ ),
34
+ input: (
35
+ selector: 'input[type="text"]',
36
+ ),
37
+ input-invalid-slot: 'after',
38
+ ));
39
+ }
40
+ }
@@ -0,0 +1,72 @@
1
+ /**
2
+ * Copyright IBM Corp. 2026
3
+ *
4
+ * This source code is licensed under the Apache-2.0 license found in the
5
+ * LICENSE file in the root directory of this source tree.
6
+ */
7
+
8
+ @use 'sass:map';
9
+
10
+ @use '@carbon/styles/scss/theme';
11
+ @use '@carbon/styles/scss/spacing';
12
+ @use '@carbon/styles/scss/utilities/focus-outline';
13
+
14
+ @use '../_layer';
15
+
16
+ @use '../../layout';
17
+ @use '../../utilities/icons';
18
+
19
+ $config: () !default;
20
+
21
+ $-default-config: (
22
+ selector: '[data-tile]',
23
+ );
24
+
25
+ /// @group tile
26
+ /// @param {Map} config [()]
27
+ /// @param {Selector} config.selector ['[data-tile]']
28
+ @mixin styles($config: $config) {
29
+ $props: map.deep-merge($-default-config, $config);
30
+
31
+ #{map.get($props, 'selector')} {
32
+ @include layer.styles;
33
+ padding: layout.$density--padding;
34
+ box-sizing: border-box;
35
+
36
+ &:is(a) {
37
+ position: relative;
38
+ display: block;
39
+ color: theme.$text-primary;
40
+ text-decoration: none;
41
+ padding-inline-end: spacing.$spacing-09;
42
+ border: 0.0625rem solid theme.$border-tile;
43
+ transition: background-color layout.$mode--transition-duration layout.$mode--transition-timing-function;
44
+
45
+ &:hover {
46
+ @include layer.layer-background-hover;
47
+ }
48
+
49
+ &:active {
50
+ @include layer.layer-background-active;
51
+ }
52
+
53
+ &:focus {
54
+ @include focus-outline.focus-outline('outline');
55
+ }
56
+
57
+ &::after {
58
+ @include icons.arrow--right;
59
+ content: '';
60
+ position: absolute;
61
+ color: theme.$link-primary;
62
+ inset-block-end: layout.$density--padding;
63
+ inset-inline-end: layout.$density--padding;
64
+ transition: color layout.$mode--transition-duration layout.$mode--transition-timing-function;
65
+ }
66
+
67
+ &:hover::after {
68
+ color: theme.$icon-primary;
69
+ }
70
+ }
71
+ }
72
+ }
@@ -0,0 +1,47 @@
1
+ /**
2
+ * Copyright IBM Corp. 2026
3
+ *
4
+ * This source code is licensed under the Apache-2.0 license found in the
5
+ * LICENSE file in the root directory of this source tree.
6
+ */
7
+
8
+ @use 'sass:map';
9
+
10
+ @use '../_labelled-input';
11
+
12
+ @use '../../utilities/icons';
13
+
14
+ $config: () !default;
15
+
16
+ $-default-config: (
17
+ selector: 'label:has(input[type="time"])',
18
+ axis: 'block',
19
+ );
20
+
21
+ /// @group time-input
22
+ /// @param {Map} config [()]
23
+ /// @param {Selector} config.selector ['label:has(input[type="time"])']
24
+ /// @param {'block' | 'axis'} config.axis ['block']
25
+ @mixin styles($config: $config) {
26
+ $props: map.deep-merge($-default-config, $config);
27
+
28
+ #{map.get($props, 'selector')} {
29
+ @include labelled-input.styles((
30
+ label: (
31
+ selector: '&',
32
+ axis: map.get($props, 'axis'),
33
+ ),
34
+ input: (
35
+ selector: 'input[type="time"]',
36
+ ),
37
+ fixed-input-trailing-slots: 1,
38
+ input-invalid-slot: 'after',
39
+ ));
40
+
41
+ &::before {
42
+ @include labelled-input.input-trailing-slot {
43
+ @include icons.time;
44
+ }
45
+ }
46
+ }
47
+ }
@@ -0,0 +1,106 @@
1
+ /**
2
+ * Copyright IBM Corp. 2026
3
+ *
4
+ * This source code is licensed under the Apache-2.0 license found in the
5
+ * LICENSE file in the root directory of this source tree.
6
+ */
7
+
8
+ @use 'sass:map';
9
+
10
+ @use '@carbon/styles/scss/theme';
11
+ @use '@carbon/styles/scss/spacing';
12
+ @use '@carbon/styles/scss/utilities/focus-outline';
13
+ @use '@carbon/styles/scss/components/button/tokens' as carbon-button;
14
+
15
+ @use '../label';
16
+
17
+ @use '../../layout';
18
+
19
+ $config: () !default;
20
+
21
+ $-default-config: (
22
+ selector: 'label:has(button[role="switch"])',
23
+ );
24
+
25
+ $-block-size: 1.5rem;
26
+ $-inline-size: 3rem;
27
+ $-knob-spacing: 0.1875rem;
28
+ $-knob-size: calc($-block-size - $-knob-spacing * 2);
29
+
30
+ /// @group toggle
31
+ /// @param {Map} config [()]
32
+ /// @param {Selector} config.selector ['label:has(button[role="switch"])']
33
+ @mixin styles($config: $config) {
34
+ $props: map.deep-merge($-default-config, $config);
35
+
36
+ #{map.get($props, 'selector')} {
37
+ @include label.styles((
38
+ selector: '&',
39
+ ));
40
+
41
+ inline-size: max-content;
42
+
43
+ & button[role="switch"] {
44
+ position: relative;
45
+ appearance: none;
46
+ border: none;
47
+ box-shadow: none;
48
+ padding: 0;
49
+ margin: 0;
50
+ block-size: $-block-size;
51
+ inline-size: $-inline-size;
52
+ border-radius: calc($-block-size * 0.5);
53
+ background-color: theme.$toggle-off;
54
+ transition: background-color layout.$mode--transition-duration layout.$mode--transition-timing-function;
55
+ cursor: pointer;
56
+
57
+ &:disabled,
58
+ &[aria-checked="true"]:disabled {
59
+ background-color: carbon-button.$button-disabled;
60
+ cursor: not-allowed;
61
+
62
+ &::before {
63
+ background-color: theme.$icon-on-color-disabled;
64
+ }
65
+ }
66
+
67
+ &:focus {
68
+ @include focus-outline.focus-outline('outline');
69
+ outline-offset: spacing.$spacing-01;
70
+ }
71
+ }
72
+
73
+ & button[role="switch"] > span {
74
+ @include layout.mode--body-compact;
75
+ position: absolute;
76
+ inset-inline-end: calc(spacing.$spacing-03 * -1);
77
+ inset-block-start: calc(($-block-size - 1lh) * 0.5);
78
+ translate: 100% 0;
79
+ }
80
+
81
+ & button[role="switch"] > span[aria-hidden="true"] {
82
+ display: none;
83
+ }
84
+
85
+ & button[role="switch"][aria-checked="true"] {
86
+ background-color: theme.$support-success;
87
+ }
88
+
89
+ & button[role="switch"]::before {
90
+ content: '';
91
+ display: block;
92
+ position: absolute;
93
+ block-size: $-knob-size;
94
+ inline-size: $-knob-size;
95
+ border-radius: 50%;
96
+ background-color: theme.$icon-on-color;
97
+ inset-inline-start: $-knob-spacing;
98
+ inset-block-start: $-knob-spacing;
99
+ transition: translate layout.$mode--transition-duration layout.$mode--transition-timing-function;
100
+ }
101
+
102
+ & button[role="switch"][aria-checked="true"]::before {
103
+ translate: calc($-inline-size - $-knob-size - $-knob-spacing * 2) 0;
104
+ }
105
+ }
106
+ }
@@ -0,0 +1,44 @@
1
+ /**
2
+ * Copyright IBM Corp. 2026
3
+ *
4
+ * This source code is licensed under the Apache-2.0 license found in the
5
+ * LICENSE file in the root directory of this source tree.
6
+ */
7
+
8
+ @use 'sass:map';
9
+
10
+ @use '@carbon/styles/scss/theme';
11
+
12
+ @use '../popover';
13
+
14
+ @use '../../layout';
15
+
16
+ $config: () !default;
17
+
18
+ $-default-config: (
19
+ selector: '[popover="hint"]',
20
+ );
21
+
22
+ /// @group tooltip
23
+ /// @param {Map} config [()]
24
+ /// @param {Selector} config.selector ['[popover="hint"]']
25
+ @mixin styles($config: $config) {
26
+ $props: map.deep-merge($-default-config, $config);
27
+
28
+ #{map.get($props, 'selector')} {
29
+ @include popover.styles((
30
+ selector: '&',
31
+ caret: true,
32
+ ));
33
+
34
+ background-color: theme.$background-inverse;
35
+ color: theme.$text-inverse;
36
+ justify-self: anchor-center;
37
+ inset-inline: unset;
38
+
39
+ &::before {
40
+ inset-inline-start: 50%;
41
+ translate: -50% 0;
42
+ }
43
+ }
44
+ }
@@ -0,0 +1,127 @@
1
+ /**
2
+ * Copyright IBM Corp. 2026
3
+ *
4
+ * This source code is licensed under the Apache-2.0 license found in the
5
+ * LICENSE file in the root directory of this source tree.
6
+ */
7
+
8
+ @use 'sass:map';
9
+ @use 'sass:string';
10
+
11
+ @use '@carbon/styles/scss/theme';
12
+ @use '@carbon/styles/scss/spacing';
13
+ @use '@carbon/styles/scss/utilities/focus-outline';
14
+
15
+ @use '../../layout';
16
+ @use '../../utilities/icons';
17
+
18
+ $config: () !default;
19
+
20
+ $-default-config: (
21
+ selector: 'ul[role="tree"]',
22
+ );
23
+
24
+ /// @group tree-view
25
+ /// @param {Map} config [()]
26
+ /// @param {Selector} config.selector ['ul[role="tree"]']
27
+ @mixin styles($config: $config) {
28
+ $props: map.deep-merge($-default-config, $config);
29
+
30
+ #{map.get($props, 'selector')} {
31
+ background-color: theme.$layer;
32
+ list-style: none;
33
+ margin: 0;
34
+ padding: 0;
35
+
36
+ & li[role="treeitem"] > :is(span, a) {
37
+ @include layout.mode--body-compact;
38
+ color: theme.$text-secondary;
39
+ display: flex;
40
+ flex-direction: row;
41
+ column-gap: spacing.$spacing-03;
42
+ block-size: layout.$size--block-size;
43
+ padding-block-start: layout.$size--padding-block-start;
44
+ padding-block-end: layout.$size--padding-block-end;
45
+ padding-inline-end: layout.$density--padding;
46
+ box-sizing: border-box;
47
+ cursor: pointer;
48
+ transition-property: color, background-color;
49
+ transition-duration: layout.$mode--transition-duration;
50
+ transition-timing-function: layout.$mode--transition-timing-function;
51
+
52
+ &:hover {
53
+ background-color: theme.$layer-hover;
54
+ color: theme.$text-primary;
55
+ }
56
+
57
+ &:active {
58
+ background-color: theme.$layer-active;
59
+ }
60
+
61
+ & > svg {
62
+ fill: currentColor;
63
+ block-size: 1rem;
64
+ inline-size: 1rem;
65
+ translate: 0 0.0625rem;
66
+ }
67
+ }
68
+
69
+ & li[role="treeitem"]:focus {
70
+ outline: none;
71
+
72
+ & > :is(span, a) {
73
+ @include focus-outline.focus-outline('outline');
74
+ }
75
+ }
76
+
77
+ & li[role="treeitem"][aria-selected="true"] > :is(span, a) {
78
+ color: theme.$text-primary;
79
+ background-color: theme.$layer-selected;
80
+ }
81
+
82
+ & li[role="treeitem"][aria-current] > :is(span, a) {
83
+ box-shadow: inset 0.25rem 0 0 0 theme.$border-interactive;
84
+ }
85
+
86
+ & li[role="treeitem"][aria-disabled="true"] > :is(span, a) {
87
+ color: theme.$text-disabled;
88
+ cursor: not-allowed;
89
+
90
+ &:hover, &:active {
91
+ background-color: transparent;
92
+ }
93
+ }
94
+
95
+ & li[role="treeitem"] > ul[role="group"] {
96
+ list-style: none;
97
+ margin: 0;
98
+ padding: 0;
99
+ }
100
+
101
+ & li[role="treeitem"][aria-expanded="false"] > ul[role="group"] {
102
+ display: none;
103
+ }
104
+
105
+ & li[role="treeitem"][aria-expanded="false"] > :is(span, a)::before {
106
+ rotate: -90deg;
107
+ }
108
+
109
+ &:has([aria-expanded]) li[role="treeitem"] > :is(span, a)::before {
110
+ content: '';
111
+ display: block;
112
+ inline-size: 1rem;
113
+ translate: 0 0.0625rem;
114
+ transition: rotate layout.$mode--transition-duration layout.$mode--transition-timing-function;
115
+ }
116
+
117
+ & li[role="treeitem"][aria-expanded] > :is(span, a)::before {
118
+ @include icons.caret--down;
119
+ }
120
+
121
+ @for $i from 1 through 16 {
122
+ & li[role="treeitem"][aria-level="#{$i}"] > :is(span, a) {
123
+ padding-inline-start: calc(layout.$density--padding * $i);
124
+ }
125
+ }
126
+ }
127
+ }
@@ -0,0 +1,46 @@
1
+ /**
2
+ * Copyright IBM Corp. 2026
3
+ *
4
+ * This source code is licensed under the Apache-2.0 license found in the
5
+ * LICENSE file in the root directory of this source tree.
6
+ */
7
+
8
+ @use 'sass:map';
9
+
10
+ @use '@carbon/styles/scss/spacing';
11
+
12
+ @use '../../layout';
13
+
14
+ $config: () !default;
15
+
16
+ $-default-config: (
17
+ selector: 'ul',
18
+ );
19
+
20
+ /// @group unordered-list
21
+ /// @param {Map} config [()]
22
+ /// @param {Selector} config.selector ['ul']
23
+ @mixin styles($config: $config) {
24
+ $props: map.deep-merge($-default-config, $config);
25
+
26
+ #{map.get($props, 'selector')} {
27
+ list-style-type: '–';
28
+ padding: 0;
29
+
30
+ & li {
31
+ @include layout.mode--body-compact;
32
+ max-inline-size: layout.$mode--max-inline-size;
33
+ margin-inline-start: layout.$density--padding;
34
+ padding-inline-start: spacing.$spacing-03;
35
+ }
36
+
37
+ & li li {
38
+ list-style-type: '▪';
39
+ }
40
+
41
+ & li p {
42
+ @include layout.mode--body-compact;
43
+ margin-block: 0;
44
+ }
45
+ }
46
+ }
package/src/index.scss ADDED
@@ -0,0 +1,10 @@
1
+ /**
2
+ * Copyright IBM Corp. 2026
3
+ *
4
+ * This source code is licensed under the Apache-2.0 license found in the
5
+ * LICENSE file in the root directory of this source tree.
6
+ */
7
+
8
+ @forward './utilities/carbon';
9
+
10
+ @forward './layout';
@@ -0,0 +1,27 @@
1
+ /**
2
+ * Copyright IBM Corp. 2026
3
+ *
4
+ * This source code is licensed under the Apache-2.0 license found in the
5
+ * LICENSE file in the root directory of this source tree.
6
+ */
7
+
8
+ @use 'sass:map';
9
+
10
+ @use '@carbon/styles/scss/spacing';
11
+
12
+ @use '../utilities/tokens';
13
+
14
+ $-densities: (
15
+ condensed: spacing.$spacing-03,
16
+ normal: spacing.$spacing-05,
17
+ );
18
+
19
+ $-default-density: 'normal';
20
+
21
+ /// @group layout--density
22
+ /// @param {'condensed' | 'normal'} density ['normal']
23
+ @mixin density($density: $-default-density) {
24
+ @include tokens.set('density--padding', map.get($-densities, $density));
25
+ }
26
+
27
+ $density--padding: tokens.get('density--padding', map.get($-densities, $-default-density));