Config Provider
Config Provider is used for providing global configurations,
Default
Badge
<script setup>
import { ref } from 'vue'
const size = ref('md')
const sizes = [
{ label: 'Small', value: 'sm' },
{ label: 'Medium', value: 'md' },
{ label: 'Large', value: 'lg' },
]
</script>
<template>
<PSwitch v-model="size" :options="sizes" />
<PConfigProvider :size="size" class="mt-4 max-w-xs">
<PStack direction="vertical">
<PToggle />
<PBadge>Badge</PBadge>
<PButton>Button</PButton>
<PInput placeholder="Input" />
<PTextarea placeholder="Textarea" />
</PStack>
</PConfigProvider>
</template>
Locale
| Jan | ||||||
|---|---|---|---|---|---|---|
| Mon | ||||||
| Wed | ||||||
| Fri | ||||||
| Less | More |
<script setup>
import { ref } from 'vue'
import { zhCN, enUS } from 'pxd/locales'
// or only import enUS
// import enUS from 'pxd/locales/en-us'
const locale = ref('enUS')
const sizes = [
{ label: 'EnUS', value: 'enUS' },
{ label: 'ZhCN', value: 'zhCN' },
]
const locales = {
zhCN,
enUS,
}
</script>
<template>
<PConfigProvider :locale="locales[locale]">
<PStack direction="vertical">
<PSwitch v-model="locale" :options="sizes" />
<PActiveGraph start-date="2025-01-01" end-date="2025-01-31" />
</PStack>
</PConfigProvider>
</template>
You can also provide only the locale values you need to override. Missing values are merged from enUS:
<PConfigProvider :locale="{ confirm: { cancel: 'Close' } }">
<PTimePicker />
</PConfigProvider>Props
| Name | Type | Default | Description |
|---|---|---|---|
| size | 'sm' | 'md' | 'lg' | md | Default size inherited by all descendant components |
| locale | LocalePatch | () => enUS | Merged with enUS |
| enter-motion | boolean | true | Set to false to drop overlay enter transitions |
| leave-motion | boolean | true | Set to false to drop overlay leave transitions |
Slots
| Name | Description |
|---|---|
| default | Default slot |