Config Provider
YhConfigProvider provides scoped or global configuration for theme color, locale, component size, z-index, and message behavior.
Theme Switching
Use the theme prop to switch the active primary color. Preset names and hex values are both supported.
Global Component Size
Use the size prop to make nested YH-UI components follow the same size.
Full Configuration Example
This example combines theme, locale, and size in one local provider scope.
Use in Nuxt
YhConfigProvider works in Nuxt SSR. Wrap the part of the page that needs scoped configuration, and the provider will apply theme styles through inline CSS variables while locale and size are passed through context.
API
Props
| Name | Description | Type | Default |
|---|---|---|---|
| theme | Global or scoped theme preset / primary color | string | PresetTheme | 'default' |
| locale | Locale object passed to nested components | Language | zhCn |
| size | Shared component size | 'small' | 'default' | 'large' | 'default' |
| z-index | Base z-index value exposed through provider context | number | 2000 |
| message | Global message behavior overrides | ConfigProviderContext['message'] | {} |
| global | Whether theme styles are applied globally instead of the local provider scope | boolean | true |
Events
This component does not expose component events.
Slots
| Name | Description | Parameters |
|---|---|---|
| default | Content rendered inside the provider scope | - |
Expose
This component does not expose public instance methods or properties.
Theme Variables
This component does not provide component-level themeOverrides. Theme, locale, size, z-index, and message behavior are passed to child components through provider context, and theme CSS variables are generated by the theme manager for the provider scope or :root.
Type Exports
| Name | Description |
|---|---|
YhConfigProviderProps | Props type for YhConfigProvider |
YhConfigProviderSlots | Slots type for YhConfigProvider |
YhConfigProviderInstance | Public instance type for YhConfigProvider |
ConfigProviderContext | Provider context type |