Skip to content

Runtime configuration change? #3290

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

Closed
m-thorsen opened this issue Feb 11, 2025 · 4 comments · Fixed by #3855
Closed

Runtime configuration change? #3290

m-thorsen opened this issue Feb 11, 2025 · 4 comments · Fixed by #3855
Labels
question Further information is requested v3 #1289

Comments

@m-thorsen
Copy link

Description

Sorry if this information is available, but I could not find an answer in the docs or by searching.

I was hoping to be able to let users select a theme that also included changing component defaults.
Using Vue/Vite (not Nuxt), is it possible to modify the full global configuration (ui object) at runtime (instead of having to pass props to or wrap each component)?

I'm not 100% averse to a bit of monkey patching on my current project, but a supported solution would obviously be much much better.

If this is not currently possible, please consider this a suggestion, for example via an ui prop on the App component or a useNuxtUi composable.

@m-thorsen m-thorsen added question Further information is requested v3 #1289 labels Feb 11, 2025
Copy link
Member

Would you have an example in mind? You want to do something like the theme switcher on the v3 docs? 🤔
CleanShot 2025-02-11 at 19.33.58@2x.png

@m-thorsen
Copy link
Author

m-thorsen commented Feb 11, 2025

Would you have an example in mind? You want to do something like the theme switcher on the v3 docs?

No, I was thinking about replacing multiple component defaults at once via the "ui object" documented here:
https://ui3.nuxt.dev/getting-started/theme#config
This includes default font weight/case for buttons, size for inputs etc... Basically, anything that can be set under "ui" in vite config.

There's a reference to useAppConfig() here: https://github.com/nuxt/ui/blob/v3/src/runtime/vue/stubs.ts
I will do some testing to see if it contains what I'm after, but at this moment I'm not sure if that's able or meant to be exposed/changed at runtime. I could not find any documentation for this.

@snackVal
Copy link

snackVal commented Feb 19, 2025

When using updateAppConfig({ ui: { ... } }), the updates are not applied to the NuxtUI components. Only the ui: { ... } options defined in defineAppConfig() are applied as intended.
It would be nice to be able to update the ui options at runtime, since it it defined in app.config that usually allows to update app config at runtime.
What do you think about it ? @benjamincanac

@DavidSabine
Copy link

DavidSabine commented Mar 19, 2025

I like this thread and I have a similar use case. With one difference:

I'd like, rather than the user 'select' a theme, to switch themes based on hostname of the http request. Imagine each of the following urls is served from the same nuxt app, but they look different based on domain name:

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
question Further information is requested v3 #1289
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants