[feature] extend Vuetify components
See original GitHub issueWhat problem does this feature solve?
Right now, AFAIK, there is easy way to extend Vuetify component. I am writing a library and I want one of my library components to extend for example VInput component. Vuetify does not export it’s components - it only exports plugin function that install those components at “runtime”. What I need is something like this:
<script>
import { Vinput } from 'vuetify/components'
export default {
extends: VInput
}
</script>
I know that components can be imported via import VInput from 'vuetify/src/components/VInput/VInput'
for example, but then to build such app I would need all loaders that vuetify uses to build/transpile its code (typescript / stylus / etc)…
What is your proposed solution?
Something like this:
<script>
import { Vinput } from 'vuetify/components' // <--------------- export all components
export default {
extends: VInput
}
</script>
Issue Analytics
- State:
- Created 5 years ago
- Reactions:8
- Comments:5 (1 by maintainers)
Top Results From Across the Web
Frequently asked questions — Vuetify
How do I extend Vuetify components? Vuetify components are easily extendable by importing it and using the extends option in vue. Codepen ...
Read more >Extend vuetify VTextField - Stack Overflow
Notice this extends from the base component ( VTextField ) and sort of "overrides" the original render function, returning customized ...
Read more >Building Packageable Components to Extend Vuetify with ...
In this installment, we're going to build out the custom component we began in the last post, a Vuetify extension called VAddressFields, ...
Read more >Vuetify extending components - CodeSandbox
Vuetify extending components ... Manage Extension. Activating extension 'vscode.typescript-language-features' failed: Could not find bundled tsserver.js.
Read more >Create wrapper components for Vuetify components
That's all there is to it! You can now use the "component wrapper" technique to extend Vuetify components and also to build apps...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Unfortunately @nekosaur’s approach of importing a component from the
vuetify/es5/components/*
path fails for me as well, because even the es5 components still somehow require the stylus loader? (same issue as @alekbarszczewski @slushnys @pynner)I have created a solution that works in the case where you’re trying to import a specific component to be able to extend it, but it will not work of you’re trying to import specific components with the intent of tree shaking.
It’s a bit hacky, but it gets the job done using the same pre-built/dist copy of the Vuetufy components that are installed globally via
Vue.use(Vuetify)
. Fortunately, using this approach also means that you can define your components that extend the Vuetify components even before Vuetify is installed globally. This approach could even be adapted to work in the (live browser/Vuetify via cdn) environment if you usewindow.Vuetify
instead of the imported version here.Let’s start by breaking all of the components free, so we never have to implement this hack in any more that one place.
VuetifyActuallyAlacarte.js
aka “Hippity Hoppity I’m Coming For That Property”In your cases, you’ll probably write something like this:
CustomVInput.js
In my case, I wanted to extend the VTextField, which has a deprecation warning wrapper obscuring the actual component that I want to extend, so I need to unwrap it to get the real component - thankfully still accessible.
CustomVTextField.js
Hopefully this helps someone else out there!
I tried it, but it complains that I need stylus loader. Would be best if it was possible to import components without modifying build step / configuration.