IconButton.vue 829 B

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  1. <template>
  2. <ElButton
  3. :type="type"
  4. :loading="loading"
  5. :disabled="disabled"
  6. :size="size"
  7. :class="{ square }"
  8. v-bind="$attrs"
  9. >
  10. <Icon :icon="icon" :color="iconColor"></Icon>
  11. <slot>{{ label }}</slot>
  12. </ElButton>
  13. </template>
  14. <script setup lang="ts">
  15. import { ElButton } from 'element-plus'
  16. import Icon from '../icon/Icon.vue'
  17. withDefaults(
  18. defineProps<{
  19. icon: string
  20. iconColor?: string
  21. size?: 'small' | 'large' | 'default'
  22. loading?: boolean
  23. type?: 'primary' | 'success' | 'warning' | 'danger' | 'info' | 'default'
  24. disabled?: boolean
  25. square?: boolean
  26. label?: string
  27. }>(),
  28. {
  29. size: 'default',
  30. type: 'default',
  31. loading: false
  32. }
  33. )
  34. </script>
  35. <style lang="less" scoped>
  36. .square {
  37. .el-button {
  38. padding: 8px;
  39. &--large {
  40. padding: 12px;
  41. }
  42. &--small {
  43. padding: 5px;
  44. }
  45. }
  46. }
  47. </style>