-
Notifications
You must be signed in to change notification settings - Fork 541
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Override default props from AppConfig
#2662
Comments
I have no idea how to implement this honestly as |
I completely forgot that Here's how other UI do it: |
We could merge with |
and we need this to be compatible with both Nuxt and Vue! This easily starts to be on a whole different level of complexity 🤔 |
@sandros94 for vue, I think you can specify |
@benjamincanac can do is add a new object, like export default defineAppConfig({
ui: {
icons: { /* ... */},
colors: { /* ... */},
theme: { /* ... */},
+ components: {
+ accordion: {
+ collapsible: false
+ }
}
}
}) |
Thank you, @hywax, for your suggestion. I also need this feature as it helps prevent a lot of code duplication and unnecessary component wrapping throughout the project. This feature has already been implemented in Vuetify, where they provide:
These features make component management significantly more efficient. FYI: I’m not sure, but they might have used the |
For what version of Nuxt UI are you suggesting this?
v3.0.0-alpha.x
Description
Hello everyone, I’d like to discuss the possibility of setting
props
by default fromAppConfig
. Currently, it’s very convenient that we can configure the theme through the config. It would be great to have a similar option for props. Previously, @benjamincanac mentioned here that this is not currently planned.My proposal is simple: wrap all
withDefaults
in our own implementation. This way, we can define props without making significant changes to the code.What it could look like
Let’s look at the
Accordion.vue
component. At the moment, its props look like this:Let’s assume our wrapper is called
withUiDefaults
. Then the code would look like this:The implementation of
withUiDefaults
is quite simple:Issues I See
Typing
AppConfig
might be challengingWe would need to somehow generate types based on the components.
My opinion: I think we can retrieve this using
vue-component-meta
during the UI build stage. So, in my opinion, this isn’t a significant problem.Developers might set
modelValue
or other critical props by defaultMy opinion: In such cases, we can log a warning to the console. Additionally, developers should understand which props they are overriding. We won’t be able to cover all edge cases, but I don’t think we need to.
Additional context
No response
The text was updated successfully, but these errors were encountered: