@kit-ng-ui/config-provider
v0.1.0
Published
Kit UI ConfigProvider — locale, direction, default size, and per-component overrides.
Downloads
27
Readme
@kit-ng-ui/config-provider
Locale, direction, default component size, and per-component default overrides for @kit-ng-ui/* components.
pnpm add @kit-ng-ui/config-providerApp-wide config
import { bootstrapApplication } from '@angular/platform-browser';
import { provideKitUi } from '@kit-ng-ui/core';
import { provideKitConfig, vi_VN } from '@kit-ng-ui/config-provider';
bootstrapApplication(AppComponent, {
providers: [
provideKitUi(),
provideKitConfig({
locale: vi_VN,
direction: 'ltr',
componentSize: 'md',
componentDefaults: {
button: { autoInsertSpace: false },
modal: { maskClosable: false },
},
}),
],
});Scoped subtree
<kit-config-provider [locale]="vn" direction="rtl">
<my-feature />
</kit-config-provider>When <kit-config-provider> is destroyed, the override is released and components fall back to the app-wide bootstrap config.
v0.1 caveat: only the closest provider wins. Nested providers do NOT merge with their ancestors — repeat the inherited keys explicitly if you need to layer.
Reading config from a component
import { inject, computed } from '@angular/core';
import { KitConfigService } from '@kit-ng-ui/config-provider';
@Component({ /* … */ })
export class MyComponent {
private readonly config = inject(KitConfigService);
protected readonly size = computed(
() => this.size() ?? this.config.componentDefaults('button').size ?? 'md',
);
}API — provideKitConfig / <kit-config-provider>
| Input | Description | Type | Default |
| ------------------- | ----------------------------------------------------------------- | ----------------------- | ------------ |
| componentDefaults | Per-component default override map. | KitComponentDefaults | {} |
| componentSize | Global default size for sized controls. | 'sm' \| 'md' \| 'lg' | 'md' |
| direction | Text direction. Mirrored to the host dir attribute. | 'ltr' \| 'rtl' | 'ltr' |
| locale | Locale bundle. Use en_US or vi_VN (more shipping with components). | KitLocale | en_US |
| prefixCls | Class prefix for portal-rendered overlays (modal/drawer/etc). | string | 'kit-' |
Locales
Currently shipped:
en_US— English (default)vi_VN— Vietnamese
Add a new locale by implementing KitLocale and passing it to provideKitConfig({ locale }).
