UNPKG

3.21 kBCSSView Raw
1@import "../props.media.css";
2@import "../props.gray-hsl.css";
3
4:where(button,input:is([type="button"],[type="submit"],[type="reset"])),
5:where(input[type="file"])::-webkit-file-upload-button,
6:where(input[type="file"])::file-selector-button {
7 --_accent: initial /* your color */;
8 --_text: initial /* your text color */;
9 --_size: initial /* your size */;
10
11 --_bg: var(--surface-3);
12 --_border: var(--surface-3);
13 --_highlight-size: 0;
14 --_highlight: hsl(var(--gray-12-hsl) / 25%);
15 --_ink-shadow: 0 1px 0 var(--surface-1);
16
17 --_icon-size: 2ch;
18 --_icon-color: var(--_accent, var(--link));
19
20 font-size: var(--_size);
21 background: var(--_bg);
22 color: var(--_text);
23 border: var(--border-size-2) solid var(--_border);
24 box-shadow:
25 var(--shadow-2),
26 0 1px var(--surface-3),
27 0 0 0 var(--_highlight-size) var(--_highlight)
28 ;
29 text-shadow: var(--_ink-shadow);
30
31 display: inline-flex;
32 justify-content: center;
33 align-items: center;
34 text-align: center;
35 gap: var(--size-2);
36
37 font-weight: var(--font-weight-7);
38 border-radius: var(--radius-2);
39 padding-block: .75ch;
40 padding-inline: 1.75ch;
41
42 user-select: none;
43 -webkit-tap-highlight-color: transparent;
44 -webkit-touch-callout: none;
45
46 transition: border-color .5s var(--ease-3) 3s;
47
48 @media (--motionOK) {
49 transition:
50 border-color .5s var(--ease-3) 3s,
51 box-shadow 145ms var(--ease-4),
52 outline-offset 145ms var(--ease-4);
53 }
54}
55
56:where(button,input:is([type="button"],[type="submit"],[type="reset"])) {
57 /* disabled */
58 &[disabled] {
59 --_bg: none;
60 --_text: var(--gray-5);
61 cursor: not-allowed;
62 box-shadow: var(--shadow-1);
63 }
64
65 /* pressing */
66 &:where(:not(:active):hover) {
67 --_highlight-size: var(--size-2);
68 transition-delay: 0s;
69 transition-duration: .25s;
70 }
71
72 /* icons */
73 & > :where(svg) {
74 flex-shrink: 0;
75 filter: drop-shadow(var(--_ink-shadow));
76 block-size: var(--_icon-size);
77 inline-size: var(--_icon-size);
78 }
79
80 & > :where(svg > *) {
81 stroke: var(--_icon-color);
82 stroke-width: var(--border-size-2);
83 }
84}
85
86/* adaptive indigo text */
87:where([type="submit"], form button:not([type],[disabled])) {
88 --_text: var(--_accent, var(--link));
89}
90
91/* red reset */
92:where([type="reset"]) {
93 --_text: var(--red-2);
94 --_border: var(--surface-3);
95
96 &:focus-visible {
97 outline-color: var(--red-6);
98 }
99}
100
101/* submit, form > button, reset matching hover border color */
102:where([type="submit"], [type="reset"], form button:not([type])):is(:hover, :focus-visible):not([disabled]) {
103 --_border: currentColor;
104}
105
106/* file input */
107:where(input[type="file"]) {
108 max-inline-size: 100%;
109 padding: 0;
110 cursor: initial;
111 align-self: flex-start;
112 border-radius: var(--radius-2);
113 border: var(--border-size-1) solid var(--surface-2);
114 box-shadow: var(--inner-shadow-4);
115 color: var(--text-2);
116}
117
118:where(input[type="file"])::-webkit-file-upload-button,
119:where(input[type="file"])::file-selector-button {
120 margin-inline-end: 1.75ch;
121 cursor: pointer;
122}
123
124/* special dark theme styles */
125:where([type="submit"]),
126:where(form button:not([type="button"])),
127:where([type="reset"]),
128:where([disabled]) {
129 --_bg: var(--surface-1);
130}