You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
@@ -149,30 +150,65 @@ import Toggle from '@vueform/toggle/dist/toggle.vue2.js'
149
150
150
151
## Styling with CSS vars
151
152
152
-
The following CSS variables can be used to customize the toggle button when using `default.css`:
153
+
The following CSS variables can be used to customize toggle when using `default.css`:
153
154
```css
154
-
--toggle-width: 3rem;
155
-
--toggle-height: 1.25rem;
156
-
--toggle-border: 0.125rem;
157
-
--toggle-font-size: 0.75rem;
158
-
--toggle-duration: 150ms;
159
-
--toggle-bg-on: #10b981;
160
-
--toggle-bg-off: #e5e7eb;
161
-
--toggle-bg-on-disabled: #d1d5db;
162
-
--toggle-bg-off-disabled: #e5e7eb;
163
-
--toggle-border-on: #10b981;
164
-
--toggle-border-off: #e5e7eb;
165
-
--toggle-border-on-disabled: #d1d5db;
166
-
--toggle-border-off-disabled: #e5e7eb;
167
-
--toggle-text-on: #ffffff;
168
-
--toggle-text-off: #374151;
169
-
--toggle-text-on-disabled: #9ca3af;
170
-
--toggle-text-off-disabled: #9ca3af;
171
-
--toggle-handle-enabled: #ffffff;
172
-
--toggle-handle-disabled: #f3f4f6;
155
+
156
+
--ms-font-size: 1rem
157
+
--ms-line-height: 1.375
158
+
--ms-bg: #FFFFFF
159
+
--ms-bg-disabled: #F3F4F6
160
+
--ms-border-color: #D1D5DB
161
+
--ms-border-width: 1px
162
+
--ms-radius: 4px
163
+
--ms-py: 0.5rem
164
+
--ms-px: 0.875rem
165
+
--ms-ring-width: 3px
166
+
--ms-ring-color: #10B98130
167
+
--ms-placeholder-color: #9CA3AF
168
+
169
+
--ms-tag-font-size: 0.875rem
170
+
--ms-tag-line-height: 1.25rem
171
+
--ms-tag-font-weight: 600
172
+
--ms-tag-bg: #10B981
173
+
--ms-tag-bg-disabled: #9CA3AF
174
+
--ms-tag-color: #FFFFFF
175
+
--ms-tag-color-disabled: #FFFFFF
176
+
--ms-tag-radius: 4px
177
+
--ms-tag-py: 0.125rem
178
+
--ms-tag-px: 0.5rem
179
+
--ms-tag-my: 0.25rem
180
+
--ms-tag-mx: 0.25rem
181
+
182
+
--ms-tag-remove-radius: 4px
183
+
--ms-tag-remove-py: 0.25rem
184
+
--ms-tag-remove-px: 0.25rem
185
+
--ms-tag-remove-my: 0rem
186
+
--ms-tag-remove-mx: 0.125rem
187
+
188
+
--ms-dropdown-bg: #FFFFFF
189
+
--ms-dropdown-border-color: #D1D5DB
190
+
--ms-dropdown-border-width: 1px
191
+
--ms-dropdown-radius: 4px
192
+
193
+
--ms-option-font-size: 1rem
194
+
--ms-option-line-height: 1.375
195
+
--ms-option-bg-pointed: #FFFFFF
196
+
--ms-option-bg-selected: #10B981
197
+
--ms-option-bg-disabled: #FFFFFF
198
+
--ms-option-bg-selected-pointed: #26C08E
199
+
--ms-option-bg-selected-disabled: #FFFFFF
200
+
--ms-option-color-pointed: #1F2937
201
+
--ms-option-color-selected: #FFFFFF
202
+
--ms-option-color-disabled: #D1D5DB
203
+
--ms-option-color-selected-pointed: #FFFFFF
204
+
--ms-option-color-selected-disabled: #D1FAE5
205
+
--ms-option-py: 0.5rem
206
+
--ms-option-px: 0.75rem
207
+
208
+
--ms-empty-color: #4B5563
173
209
```
174
210
175
-
You might override them globally:
211
+
Override them globally:
176
212
177
213
``` css
178
214
:root {
@@ -184,25 +220,25 @@ You might override them globally:
184
220
Or on an instance level:
185
221
186
222
```vue
187
-
<Toggle v-model="value" class="my-toggle-red" />
188
-
<Toggle v-model="value" class="my-toggle-blue" />
223
+
<Toggle v-model="value" class="toggle-red" />
224
+
<Toggle v-model="value" class="toggle-blue" />
189
225
```
190
226
191
227
```css
192
-
.my-toggle-red {
228
+
.toggle-red {
193
229
--toggle-bg-on: red;
194
230
--toggle-border-on: red;
195
231
}
196
232
197
-
.my-toggle-blue {
233
+
.toggle-blue {
198
234
--toggle-bg-on: blue;
199
235
--toggle-border-on: blue;
200
236
}
201
237
```
202
238
203
239
## Styling with Tailwind CSS
204
240
205
-
The `Toggle` component accepts a `classes` property where you can override default class names. In this case you don't need to required`default.css`. Here's a default styling for Tailwind CSS:
241
+
The `Toggle` component accepts a `classes` property which allows to override default class names. When using utility classes you don't need to import`default.css`. Here's a default styling for Tailwind CSS:
206
242
207
243
```vue
208
244
<Toggle v-model="value" :classes="{
@@ -221,15 +257,12 @@ The `Toggle` component accepts a `classes` property where you can override defau
221
257
}" />
222
258
```
223
259
224
-
If the button is **enabled** and **on** the `toggle` and `toggleOn` classes will be added to the toggle div:
Certain classes has different states which are merged to the base class when the state is active. For exmple `handle` will be merged with `handleOn` when the toggle is **on** and **not disabled** resulting in the following classes:
This way you can customize the parts of the toggle button without having to worry about over-riding the same type of utility classes, like backgrounds or text colors.
265
+
In case you need to override the same type of utility you might use [@neojp/tailwind-important-variant](https://www.npmjs.com/package/@neojp/tailwindcss-important-variant) and use eg. `bg-green-500!`.
233
266
234
267
## Accessibility
235
268
@@ -261,7 +294,7 @@ Join our [Discord channel](https://discord.gg/WhX2nG6GTQ) or [open an issue](htt
261
294
|**onLabel**|`string`|| The label when toggle is `on`. |
262
295
|**labelledby**|`string`|| The `aria-labelledby` attribute. |
263
296
|**describedby**|`string`|| The `aria-describedby` attribute. |
264
-
|**classes**|`object`||The object of classes to be applied for different parts of the toggle. Default: `{`<br> `container: 'toggle-container',`<br> `toggle: 'toggle',`<br> `toggleOn: 'toggle-on',`<br> `toggleOff: 'toggle-off',`<br> `toggleOnDisabled: 'toggle-on-disabled',`<br> `toggleOffDisabled: 'toggle-off-disabled',`<br> `handle: 'toggle-handle',`<br> `handleOn: 'toggle-handle-on',`<br> `handleOff: 'toggle-handle-off',`<br> `handleOnDisabled: 'toggle-handle-on-disabled',`<br> `handleOffDisabled: 'toggle-handle-off-disabled',`<br> `label: 'toggle-label',`<br>`}`.<br> The default value can be used with `default.css` and style can be customized with [CSS variables](#styling-with-css-vars). Alternatively this can be overridden with utility classes like [Tailwind CSS](#styling-with-tailwind-css). |
297
+
|**classes**|`object`||An object of class names that gets merged with the default values. Default: `{`<br> `container: 'toggle-container',`<br> `toggle: 'toggle',`<br> `toggleOn: 'toggle-on',`<br> `toggleOff: 'toggle-off',`<br> `toggleOnDisabled: 'toggle-on-disabled',`<br> `toggleOffDisabled: 'toggle-off-disabled',`<br> `handle: 'toggle-handle',`<br> `handleOn: 'toggle-handle-on',`<br> `handleOff: 'toggle-handle-off',`<br> `handleOnDisabled: 'toggle-handle-on-disabled',`<br> `handleOffDisabled: 'toggle-handle-off-disabled',`<br> `label: 'toggle-label',`<br>`}`.<br> The default value can be used with `default.css` and style can be customized with [CSS variables](#styling-with-css-vars). Alternatively this can be overridden with utility classes like [Tailwind CSS](#styling-with-tailwind-css). |
0 commit comments