Skip to main content

ConfigProvider

VEF's global configuration provider. Wraps Ant Design's ConfigProvider with VEF-specific theme support including dark mode, semantic color overrides, and global CSS variables.

VEF-specific component. Extends Ant Design's ConfigProvider.

When to Use​

  • Set up the global theme at the application root.
  • Enable dark mode.
  • Override semantic colors.
  • Set application-wide defaults for whitelisted component props.
  • Inject global CSS variables.

Basic Usage​

import { ConfigProvider } from '@vef-framework-react/components';

export default function App() {
return (
<ConfigProvider>
<YourApp />
</ConfigProvider>
);
}

Dark Mode​

import { ConfigProvider } from '@vef-framework-react/components';

export default function App({ isDark }: { isDark: boolean }) {
return (
<ConfigProvider theme={{ isDarkMode: isDark }}>
<YourApp />
</ConfigProvider>
);
}

Custom Colors​

import { ConfigProvider } from '@vef-framework-react/components';

export default function App() {
return (
<ConfigProvider
theme={{
colors: {
primary: 'blue',
success: 'green',
warning: 'gold',
error: 'red',
},
}}
>
<YourApp />
</ConfigProvider>
);
}

Detect Dark Mode​

import { useIsDarkMode } from '@vef-framework-react/components';

export default function MyComponent() {
const isDark = useIsDarkMode();
return <div style={{ color: isDark ? '#fff' : '#000' }}>Content</div>;
}

Application Component Defaults​

components sets application-wide defaults for a whitelisted set of component props. An explicitly passed non-undefined prop wins over the application default, and the component's own default applies only when neither is set.

import { ConfigProvider } from '@vef-framework-react/components';

export default function App() {
return (
<ConfigProvider
components={{
Form: { labelAlign: 'left', labelWidth: 120 },
Pagination: { showSizeChanger: false },
ProTable: { striped: true },
}}
>
<YourApp />
</ConfigProvider>
);
}

Only these entries are honored. An object literal with extra props is rejected by TypeScript; a value built before it reaches the provider is still filtered at runtime:

ComponentDefaultable props
FormlabelAlign, labelWidth
FormModaldraggable
Imagefallback
InputallowClear, autoComplete
Messageduration, maxCount
Notificationduration, maxCount
PaginationshowSizeChanger
ProTablerowKey, showSequenceColumn, striped
SelectshowSearch
TextAreaallowClear, autoComplete

For the starter, pass components to createApp().render() instead of nesting another ConfigProvider.

API​

ConfigProviderProps​

PropTypeDefaultDescription
themeThemeConfig—Theme configuration
componentsComponentDefaults—Application-wide default props for whitelisted framework components
childrenReactNode—Application content

ThemeConfig​

FieldTypeDefaultDescription
isDarkModebooleanfalseEnable dark mode
colorsPartial<Record<SemanticColor, PresetColor | string>>—Override semantic colors (primary / success / warning / error / …) with a preset color name or any CSS color

useIsDarkMode()​

Returns boolean — true if dark mode is currently active.

Best Practices​

  • Place ConfigProvider at the root of your application, wrapping everything.
  • Use useIsDarkMode() in components that need to adapt to the current theme.