diff --git a/packages/vant/src/checkbox-group/index.ts b/packages/vant/src/checkbox-group/index.ts
index 6de4d9b00..02c1881f4 100644
--- a/packages/vant/src/checkbox-group/index.ts
+++ b/packages/vant/src/checkbox-group/index.ts
@@ -6,5 +6,6 @@ export default CheckboxGroup;
export type { CheckboxGroupProps };
export type {
CheckboxGroupInstance,
+ CheckboxGroupDirection,
CheckboxGroupToggleAllOptions,
} from './types';
diff --git a/packages/vant/src/checkbox-group/types.ts b/packages/vant/src/checkbox-group/types.ts
index af3228ec9..6bdc693dc 100644
--- a/packages/vant/src/checkbox-group/types.ts
+++ b/packages/vant/src/checkbox-group/types.ts
@@ -1,6 +1,8 @@
import type { ComponentPublicInstance } from 'vue';
import type { CheckboxGroupProps } from './CheckboxGroup';
-import type { CheckerParent } from '../checkbox/Checker';
+import type { CheckerParent, CheckerDirection } from '../checkbox/Checker';
+
+export type CheckboxGroupDirection = CheckerDirection;
export type CheckboxGroupToggleAllOptions =
| boolean
diff --git a/packages/vant/src/checkbox/Checker.tsx b/packages/vant/src/checkbox/Checker.tsx
index 4864051be..286e56f3e 100644
--- a/packages/vant/src/checkbox/Checker.tsx
+++ b/packages/vant/src/checkbox/Checker.tsx
@@ -116,13 +116,10 @@ export default defineComponent({
};
return () => {
- const nodes: (JSX.Element | undefined)[] = [renderIcon()];
-
- if (props.labelPosition === 'left') {
- nodes.unshift(renderLabel());
- } else {
- nodes.push(renderLabel());
- }
+ const nodes: (JSX.Element | undefined)[] =
+ props.labelPosition === 'left'
+ ? [renderLabel(), renderIcon()]
+ : [renderIcon(), renderLabel()];
return (
void;
diff --git a/packages/vant/src/radio-group/RadioGroup.tsx b/packages/vant/src/radio-group/RadioGroup.tsx
index 8853ee783..6eff65b06 100644
--- a/packages/vant/src/radio-group/RadioGroup.tsx
+++ b/packages/vant/src/radio-group/RadioGroup.tsx
@@ -11,10 +11,12 @@ import type { CheckerDirection } from '../checkbox/Checker';
const [name, bem] = createNamespace('radio-group');
+export type RadioGroupDirection = CheckerDirection;
+
const props = {
disabled: Boolean,
iconSize: numericProp,
- direction: String as PropType,
+ direction: String as PropType,
modelValue: unknownProp,
checkedColor: String,
};
diff --git a/packages/vant/src/radio-group/index.ts b/packages/vant/src/radio-group/index.ts
index d9ed7e66c..d2c910819 100644
--- a/packages/vant/src/radio-group/index.ts
+++ b/packages/vant/src/radio-group/index.ts
@@ -1,5 +1,6 @@
import { withInstall } from '../utils';
-import _RadioGroup from './RadioGroup';
+import _RadioGroup, { RadioGroupDirection } from './RadioGroup';
export const RadioGroup = withInstall(_RadioGroup);
export default RadioGroup;
+export type { RadioGroupDirection };
diff --git a/packages/vant/src/radio/README.md b/packages/vant/src/radio/README.md
index bb229f0a1..422e2c190 100644
--- a/packages/vant/src/radio/README.md
+++ b/packages/vant/src/radio/README.md
@@ -156,6 +156,14 @@ export default {
```
+### Types
+
+The component exports the following type definitions:
+
+```ts
+import type { RadioShape, RadioLabelPosition, RadioGroupDirection } from 'vant';
+```
+
## API
### Radio Props
diff --git a/packages/vant/src/radio/README.zh-CN.md b/packages/vant/src/radio/README.zh-CN.md
index b95a59b98..c527d45b6 100644
--- a/packages/vant/src/radio/README.zh-CN.md
+++ b/packages/vant/src/radio/README.zh-CN.md
@@ -181,7 +181,7 @@ export default {
| disabled | 是否为禁用状态 | _boolean_ | `false` |
| label-disabled | 是否禁用文本内容点击 | _boolean_ | `false` |
| label-position | 文本位置,可选值为 `left` | _string_ | `right` |
-| icon-size | 图标大小,默认单位为`px` | _number \| string_ | `20px` |
+| icon-size | 图标大小,默认单位为 `px` | _number \| string_ | `20px` |
| checked-color | 选中状态颜色 | _string_ | `#1989fa` |
### RadioGroup Props
@@ -190,8 +190,8 @@ export default {
| --- | --- | --- | --- |
| v-model | 当前选中项的标识符 | _any_ | - |
| disabled | 是否禁用所有单选框 | _boolean_ | `false` |
-| direction | 排列方向,可选值为`horizontal` | _string_ | `vertical` |
-| icon-size | 所有单选框的图标大小,默认单位为`px` | _number \| string_ | `20px` |
+| direction | 排列方向,可选值为 `horizontal` | _string_ | `vertical` |
+| icon-size | 所有单选框的图标大小,默认单位为 `px` | _number \| string_ | `20px` |
| checked-color | 所有单选框的选中状态颜色 | _string_ | `#1989fa` |
### Radio Events
@@ -213,6 +213,14 @@ export default {
| default | 自定义文本 | - |
| icon | 自定义图标 | _{ checked: boolean, disabled: boolean }_ |
+### 类型定义
+
+组件导出以下类型定义:
+
+```ts
+import type { RadioShape, RadioLabelPosition, RadioGroupDirection } from 'vant';
+```
+
## 主题定制
### 样式变量
diff --git a/packages/vant/src/radio/Radio.tsx b/packages/vant/src/radio/Radio.tsx
index 14d93e4b5..86e55cef4 100644
--- a/packages/vant/src/radio/Radio.tsx
+++ b/packages/vant/src/radio/Radio.tsx
@@ -8,7 +8,14 @@ import { RADIO_KEY } from '../radio-group/RadioGroup';
import { useParent } from '@vant/use';
// Components
-import Checker, { checkerProps } from '../checkbox/Checker';
+import Checker, {
+ checkerProps,
+ CheckerShape,
+ CheckerLabelPosition,
+} from '../checkbox/Checker';
+
+export type RadioShape = CheckerShape;
+export type RadioLabelPosition = CheckerLabelPosition;
const [name, bem] = createNamespace('radio');
diff --git a/packages/vant/src/radio/index.ts b/packages/vant/src/radio/index.ts
index 232718798..517711c5d 100644
--- a/packages/vant/src/radio/index.ts
+++ b/packages/vant/src/radio/index.ts
@@ -1,5 +1,6 @@
import { withInstall } from '../utils';
-import _Radio from './Radio';
+import _Radio, { RadioShape, RadioLabelPosition } from './Radio';
export const Radio = withInstall(_Radio);
export default Radio;
+export type { RadioShape, RadioLabelPosition };