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
You can extend some types to use your own values (e.g. colors, sizes). This requires the use of interface augmentation. You can augment next interfaces:
248
+
249
+
- BaseColorVariant
250
+
- BaseButtonVariant (extends BaseColorVariant)
251
+
- BaseTextColorVariant (extends BaseColorVariant)
252
+
- BaseSize
253
+
- BaseInputSize
254
+
255
+
Suppose we want to add a purple style and extra-large (xl) sizes.
256
+
We need to create a declaration file in the root of vue project.
257
+
258
+
**shims-bootstrap-vue-3.d.ts**
259
+
260
+
```ts
261
+
import'bootstrap-vue-3'
262
+
263
+
declaremodule'bootstrap-vue-3/dist/types' {
264
+
exportinterfaceBaseColorVariant {
265
+
'purple':unknown// we use unknown type because it does not matter here
266
+
}
267
+
exportinterfaceBaseButtonVariant {
268
+
// there is no need to add "purple" (it inherits from BaseColorVariant)
269
+
'outline-purple':unknown// outline purple button
270
+
}
271
+
exportinterfaceBaseTextColorVariant {
272
+
// there is no need to add "purple" (it inherits from BaseColorVariant)
273
+
}
274
+
exportinterfaceBaseSize {
275
+
'xl':unknown// extra large
276
+
}
277
+
exportinterfaceBaseInputSize {
278
+
'xl':unknown// extra large (not inherits from BaseSize)
279
+
}
280
+
}
281
+
```
282
+
283
+
New values can be used now and the type check will be successful:
284
+
285
+
```html
286
+
<b-buttonvariant="purple"size="xl">Extra large purple button</b-button>
0 commit comments