Skip to content

Commit f64f4a0

Browse files
committed
feat(button): support the spinnerPlacement prop
1 parent 64aaf89 commit f64f4a0

File tree

2 files changed

+9
-3
lines changed

2 files changed

+9
-3
lines changed

packages/components/button/src/Button.vue

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,10 @@ import { useButton, type ButtonProps } from "./use-button";
33
44
import { computed, ref, type Component } from "vue";
55
6-
const props = withDefaults(defineProps<ButtonProps>(), {});
6+
const props = withDefaults(defineProps<ButtonProps>(), {
7+
spinnerPlacement: "start",
8+
isLoading: false,
9+
});
710
811
defineSlots<{
912
default(): Component;
@@ -19,8 +22,12 @@ const bind = useButton(props, buttonRef);
1922
<template>
2023
<button ref="buttonRef" v-bind="bind">
2124
<slot name="startContent" />
22-
<slot name="spinner" />
25+
<slot
26+
v-if="isLoading && props.spinnerPlacement === 'start'"
27+
name="spinner"
28+
/>
2329
<slot />
30+
<slot v-if="isLoading && props.spinnerPlacement === 'end'" name="spinner" />
2431
<slot name="endContent" />
2532
</button>
2633
</template>

packages/components/button/src/use-button.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,6 @@ export function useButton(
6464
disableAnimation = false,
6565
isDisabled: isDisabledProp = false,
6666
isIconOnly = false,
67-
spinnerPlacement = "start",
6867
} = { ...originalProps, ...attrs };
6968

7069
disableRipple.value = disableRippleProp || disableAnimation;

0 commit comments

Comments
 (0)