For AI agents: the complete documentation index is available at https://ifhover.github.io/leaf-ui/v/0.6.0/en/llms.txt, the full documentation bundle is available at https://ifhover.github.io/leaf-ui/v/0.6.0/en/llms-full.txt, and this page is available as Markdown at https://ifhover.github.io/leaf-ui/v/0.6.0/en/components/config-provider.md.
locale changes built-in text in date panels, empty states and clear actions. Translate business headings, field labels and options in your application.
These translations are included without importing a language pack. The default is Simplified Chinese when locale is not configured.
Language
locale
简体中文 (Simplified Chinese)
zh-CN
繁體中文 (Traditional Chinese)
zh-TW
English
en-US
日本語 (Japanese)
ja-JP
한국어 (Korean)
ko-KR
For another language, provide translation resources. A language tag alone does not translate built-in text. Missing entries ultimately fall back to English.
Update locale to switch languages. Select a language from the dropdown, then open the date or empty-options control to compare built-in text in all five languages.
Nested regions inherit their parent language unless overridden. direction controls text direction; weekStartsOn sets the first day of the week. Popups inherit these settings too.
Copy the complete English JSON, translate it, and pass your imported file through translations. Each key is a language tag. The JSON contains component groups and text only; do not repeat the language tag inside it. Partial resources are supported.
👽 A small Easter egg: this example uses “Martian” text, a playful style of Chinese internet writing that mixes homophones, lookalike characters, and symbols.
Missing entries fall back to English. Application content such as field names and confirmation descriptions remains under your control.
It uses the private-use language tag zh-CN-x-mars, so dates and numbers retain Simplified Chinese regional formatting. This is a demonstration, not a built-in language.
translations.tsx
import { Button, ConfigProvider, DatePicker, Form, FormField, Pagination, Select, Space, useConfirm } from '@ifhover/leaf-ui';import mars from '../../config-provider/zh-CN-x-mars.json';const translations = { 'zh-CN-x-mars': mars };function Controls() { const { confirm } = useConfirm(); return ( <Space direction="vertical" align="stretch"> <Form> <FormField label="Date"> <DatePicker /> </FormField> <FormField label="Empty options"> <Select options={[]} /> </FormField> </Form> <Pagination total={24} showTotal /> <Button variant="outline" onClick={() => void confirm({ title: 'Continue?', children: 'Confirm and Cancel use Martian text. Missing translations fall back to English.', }) } > Open confirmation </Button> </Space> );}export function ConfigProviderTranslations() { return ( <ConfigProvider locale={['zh-CN-x-mars', 'en-US']} translations={translations}> <Controls /> </ConfigProvider> );}
locale={['zh-CN-x-mars', 'en-US']} looks up each missing entry in order, with built-in English as the final fallback. The first tag always controls the current language and regional date and number formatting. A string equals a one-item array; empty arrays are invalid. No implicit zh-CN-x-mars → zh-CN or fr-CA → fr fallback is added.
Nested translations merge by language and entry. An omitted locale inherits the chain; an explicit value replaces it. Text supplied through component props or components takes precedence. See Translation resources for types, JSON Schema and validation.
density="compact" reduces control sizes and content spacing for information-heavy interfaces. The default is comfortable. Nested regions can choose their own density.
Set theme.controlHeight to change the size baseline. Small and large controls derive their heights automatically, so individual buttons and inputs stay consistent.
For further customization, see Theming. theme.components changes local component styles; components below sets default component props. For server rendering, see SSR.
Set common props once instead of repeating them on every component. Use components to share button styles, input hints and modal closing behavior. Change the configuration once when your conventions change.
Configure the app root to apply defaults throughout the app, or wrap a region to keep them local. Individual components can still override them with their own props.
Keep an accidental mask click from interrupting an edit: set Modal: { maskClosable: false } once for every Modal in the region. The close button and Esc still work.
modal-defaults.tsx
import { Button, ConfigProvider, Modal, Paragraph } from '@ifhover/leaf-ui';import { useState } from 'react';export function ConfigProviderModalDefaults() { const [open, setOpen] = useState(false); return ( <ConfigProvider components={{ Modal: { maskClosable: false } }}> <Button onClick={() => setOpen(true)}>Open modal</Button> <Modal open={open} title="Mask clicks keep this open" onClose={() => setOpen(false)}> <Paragraph> Try clicking outside the modal. It stays open. The close button, footer actions and Esc still close it. </Paragraph> </Modal> </ConfigProvider> );}
First day of the week; 0 is Sunday and 1 is Monday.
getPopupContainer
() => Element | DocumentFragment
—
Return a popup container, including a ShadowRoot.
maskBlur
boolean
true
Enable mask blur for Modal, Drawer and Modal-based overlays such as confirmations and command palettes. Disable to reduce rendering cost; nested providers inherit it.
density
'comfortable' | 'compact'
'comfortable'
Inherited controls, forms, menus, lists and overlay spacing; explicit sizes override the preset.
Regional component defaults, inherited by component and prop.
Native div props, className and style apply to the region wrapper. maskBlur={false} disables backdrop blur while preserving the translucent mask; this is independent of theme.motion.