summaryrefslogtreecommitdiffhomepage
path: root/packages/ui/src/components/switch.css
blob: 4951e599898d11be94b3f7a9e1e29baf647796b5 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
[data-component="switch"] {
	position: relative;
	display: flex;
	align-items: center;
	gap: 8px;
	cursor: default;

	[data-slot="switch-input"] {
		position: absolute;
		width: 1px;
		height: 1px;
		padding: 0;
		margin: -1px;
		overflow: hidden;
		clip: rect(0, 0, 0, 0);
		white-space: nowrap;
		border-width: 0;
	}

	[data-slot="switch-control"] {
		display: inline-flex;
		align-items: center;
		width: 28px;
		height: 16px;
		flex-shrink: 0;
		border-radius: 3px;
		border: 1px solid var(--border-weak-base);
		background: var(--surface-base);
		transition-property: background-color, border-color, box-shadow;
		transition-duration: var(--transition-duration);
		transition-timing-function: var(--transition-easing);
	}

	[data-slot="switch-thumb"] {
		width: 14px;
		height: 14px;
		box-sizing: content-box;

		border-radius: 2px;
		border: 1px solid var(--border-base);
		background: var(--icon-invert-base);

		/* shadows/shadow-xs */
		box-shadow:
			0 1px 2px -1px rgba(19, 16, 16, 0.04),
			0 1px 2px 0 rgba(19, 16, 16, 0.06),
			0 1px 3px 0 rgba(19, 16, 16, 0.08);

		transform: translateX(-1px);
		transition-property: transform, background-color, border-color;
		transition-duration: var(--transition-duration);
		transition-timing-function: var(--transition-easing);
	}

	[data-slot="switch-label"] {
		user-select: none;
		color: var(--text-base);
		font-family: var(--font-family-sans);
		font-size: var(--font-size-small);
		font-style: normal;
		font-weight: var(--font-weight-regular);
		line-height: var(--line-height-large);
		letter-spacing: var(--letter-spacing-normal);
	}

	[data-slot="switch-description"] {
		color: var(--text-base);
		font-family: var(--font-family-sans);
		font-size: 12px;
		font-weight: var(--font-weight-regular);
		line-height: var(--line-height-normal);
		letter-spacing: var(--letter-spacing-normal);
	}

	[data-slot="switch-error"] {
		color: var(--text-error);
		font-family: var(--font-family-sans);
		font-size: 12px;
		font-weight: var(--font-weight-regular);
		line-height: var(--line-height-normal);
		letter-spacing: var(--letter-spacing-normal);
	}

	&:hover:not([data-disabled], [data-readonly]) [data-slot="switch-control"] {
		border-color: var(--border-hover);
		background-color: var(--surface-hover);
	}

	&:focus-within:not([data-readonly]) [data-slot="switch-control"] {
		border-color: var(--border-focus);
		box-shadow: 0 0 0 2px var(--surface-focus);
	}

	&[data-checked] [data-slot="switch-control"] {
		box-sizing: border-box;
		border-color: var(--icon-strong-base);
		background-color: var(--icon-strong-base);
	}

	&[data-checked] [data-slot="switch-thumb"] {
		border: none;
		transform: translateX(12px);
		background-color: var(--icon-invert-base);
	}

	&[data-checked]:hover:not([data-disabled], [data-readonly])
		[data-slot="switch-control"] {
		border-color: var(--border-hover);
		background-color: var(--surface-hover);
	}

	&[data-disabled] {
		cursor: not-allowed;
	}

	&[data-disabled] [data-slot="switch-control"] {
		border-color: var(--border-disabled);
		background-color: var(--surface-disabled);
	}

	&[data-disabled] [data-slot="switch-thumb"] {
		background-color: var(--icon-disabled);
	}

	&[data-invalid] [data-slot="switch-control"] {
		border-color: var(--border-error);
	}

	&[data-readonly] {
		cursor: default;
		pointer-events: none;
	}
}