IconButton.vue 753 B

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