diff --git a/components/button/button.tsx b/components/button/button.tsx index 24db91b23..5ed5667f3 100644 --- a/components/button/button.tsx +++ b/components/button/button.tsx @@ -48,6 +48,10 @@ export const buttonProps = { type: String as PropType, default: 'default', }, + iconPlacement: { + type: String as PropType<'left' | 'right'>, + default: 'left', + }, } as const satisfies ComponentObjectPropsOptions; export type ButtonProps = ExtractPublicPropTypes; @@ -108,12 +112,11 @@ export default defineComponent({ > {props.loading ? ( - + ) - : ( - slots.icon?.() - )} + : props.iconPlacement !== 'right' && {slots.icon?.()} } {slots.default?.()} + {props.iconPlacement === 'right' && {slots.icon?.()} } ); }, diff --git a/components/button/style/index.less b/components/button/style/index.less index eb426311c..9092d30c1 100644 --- a/components/button/style/index.less +++ b/components/button/style/index.less @@ -238,8 +238,14 @@ &-long { width: 100%; } - & > .@{fes-icon-cls} { + &-icon { + display: inline-flex; + align-items: center; margin-right: 4px; + &.is-right { + margin-right: 0; + margin-left: 4px; + } } &-large { diff --git a/docs/.vitepress/components/button/icon.vue b/docs/.vitepress/components/button/icon.vue index a8c42ef62..dd03c69a1 100644 --- a/docs/.vitepress/components/button/icon.vue +++ b/docs/.vitepress/components/button/icon.vue @@ -8,7 +8,7 @@ Default - + Primary diff --git a/docs/.vitepress/components/button/index.md b/docs/.vitepress/components/button/index.md index f0f705d9d..a02074781 100644 --- a/docs/.vitepress/components/button/index.md +++ b/docs/.vitepress/components/button/index.md @@ -41,6 +41,7 @@ long.vue | long | 按钮按钮宽度为父元素宽度 | boolean | `false` | | throttle | 节流 | number | `300` | | type | 设置按钮类型,可选值为 `primary` `text` `link` `info` `success` `warning` `danger` | string | `default` | +| iconPlacement | icon位置,可选值为 `left` `right` | string | `left` | ## Slots