Skip to content

สถานะว่างเปล่า

การใช้งานพื้นฐาน

Image Slot Here
No results found
Try a different search term
vue
<template>
  <spr-empty-state description="No results found" subDescription="Try a different search term">
    <div>Image Here</div>

    <template #button>
      <spr-button tone="success">Retry</spr-button>
    </template>
  </spr-empty-state>
</template>

รูปภาพ

คุณยังสามารถใช้พร็อพส์ image เพื่อแสดงรูปภาพในสถานะว่างเปล่าที่กำหนด พร็อพส์ image ยอมรับค่าตัวอักษรที่ตรงกับชื่อของรูปภาพ

รายการรูปภาพที่สามารถใช้ได้ในคอมโพเนนต์สถานะว่างเปล่า

  • bug
  • clock
  • dashboard
  • employees
  • government-id
  • integration
  • list
  • social-media-handles
  • work-in-progress
  • work-location
empty
Current image is bug
Try a different image
vue
<template>
  <spr-empty-state
    :description="`Current image is ${currentImage}`"
    subDescription="Try a different image"
    :image="currentImage"
  >
    <template #button>
      <div class="spr-flex spr-flex-col spr-gap-4">
        <spr-button tone="success">Retry</spr-button>
        <spr-button variant="secondary" @click="changeImage">Change Image</spr-button>
      </div>
    </template>
  </spr-empty-state>
</template>

<script setup>
import { ref } from 'vue';

const imageTypes = [
  'bug',
  'clock',
  'dashboard',
  'employees',
  'government-id',
  'integration',
  'list',
  'social-media-handles',
  'work-in-progress',
  'work-location',
];

const currentImage = ref('bug');

const changeImage = () => {
  // Get the current index of the image
  const currentIndex = imageTypes.indexOf(currentImage.value);
  // Move to the next image in the array, or back to the first if at the end
  const nextIndex = (currentIndex + 1) % imageTypes.length;
  currentImage.value = imageTypes[nextIndex];
};
</script>

ขนาดรูปภาพ

ขนาดรูปภาพสามารถควบคุมได้โดยส่งพร็อพส์ size ขนาดเริ่มต้นคือ small (small และ large)

empty
No results found
Try a different search term
empty
No results found
Try a different search term
vue
<template>
  <spr-empty-state description="No results found" subDescription="Try a different search term" image="bug" size="small">
    <template #button>
      <spr-button tone="success">Retry</spr-button>
    </template>
  </spr-empty-state>

  <spr-empty-state
    description="No results found"
    subDescription="Try a different search term"
    image="work-location"
    size="large"
  >
    <template #button>
      <spr-button tone="success">Retry</spr-button>
    </template>
  </spr-empty-state>
</template>

เร็ว ๆ นี้

แสดงข้อความที่จะมาเร็ว ๆ นี้โดยใช้เพียงพร็อพส์คำอธิบายโดยไม่มีรูปภาพหรือปุ่มเพิ่มเติม:

empty
Coming Soon
Try a different search term.
vue
<template>
  <spr-empty-state description="Coming Soon" />
</template>

API Reference

Props

ชื่อคำอธิบายประเภทค่าที่มีค่าเริ่มต้น
descriptionข้อความคำอธิบายหลักสำหรับสถานะว่างเปล่า ข้อความนี้แสดงอย่างเด่นชัดเพื่อแจ้งผู้ใช้เกี่ยวกับการขาดเนื้อหาหรือผลการค้นหาStringสตริงข้อความใดๆ'No results found'
subDescriptionข้อความเพิ่มเติมที่ให้บริบทหรือคำแนะนำเพิ่มเติมสำหรับสถานะว่างเปล่า ข้อความรองนี้ปรากฏใต้คำอธิบายหลักด้วยสีที่อ่อนกว่าเพื่อให้คำอธิบายหรือคำแนะนำเพิ่มเติมStringสตริงข้อความใดๆ'Try a different search term.'
sizeควบคุมขนาดโดยรวมของคอมโพเนนต์สถานะว่างเปล่า ซึ่งส่งผลต่อทั้งมิติของคอนเทนเนอร์และขนาดรูปภาพ:
  • small: การแสดงที่กระชับมากขึ้น (min-height: 240px, image: 120x120px)
  • large: การแสดงที่เด่นชัดมากขึ้น (min-height: 360px, image: 200x200px)
String'small', 'large''small'
imageระบุรูปภาพที่กำหนดไว้ล่วงหน้าเพื่อแสดงในสถานะว่างเปล่า คอมโพเนนต์โหลดรูปภาพ SVG จากไดเรกทอรี assets โดยอัตโนมัติตามค่าพร็อพส์นี้ สิ่งนี้ใช้เมื่อไม่มีรูปภาพปรับแต่งที่ให้ผ่านสล็อตเริ่มต้นString'bug', 'clock', 'dashboard', 'employees', 'government-id', 'integration', 'list', 'social-media-handles', 'work-in-progress', 'work-location''list'
hasButtonระบุว่าสถานะว่างเปล่ามีปุ่มหรือไม่ เมื่อตั้งเป็น true คอมโพเนนต์คาดหวังเนื้อหาที่จะให้ในสล็อตปุ่ม พร็อพส์นี้ใช้สำหรับการจัดการสถานะภายในเป็นหลักBooleantrue, falsefalse
emptyStateCustomClassesคลาส CSS เพิ่มเติมที่จะใช้กับคอนเทนเนอร์สถานะว่างเปล่า สิ่งนี้ช่วยให้การจัดสไตล์ปรับแต่งโดยไม่ต้องแก้ไขการจัดสไตล์ภายในของคอมโพเนนต์Stringสตริงคลาส CSS ที่ถูกต้องใดๆ''

Events

ชื่อคำอธิบายพารามิเตอร์
onClickปล่อยเมื่อคลิกคอมโพเนนต์สถานะว่างเปล่า อีเวนต์นี้กำหนดในคอมโพเนนต์แต่ไม่ปล่อยอย่างแข็งขันในการใช้งานปัจจุบันไม่มี

Slots

ชื่อคำอธิบาย
defaultสล็อตเริ่มต้นสามารถใช้เพื่อแทนรูปภาพที่กำหนดไว้ล่วงหน้าด้วยเนื้อหาปรับแต่ง หากให้ สล็อตเนื้อหานี้จะแสดงแทนรูปภาพที่ระบุโดยพร็อพส์ image เนื้อหาจะได้รับคลาสขนาดเดียวกันกับที่รูปภาพที่กำหนดไว้ล่วงหน้าจะมี ตามพร็อพส์ size
buttonใช้เพื่อให้ปุ่มการดำเนินการหรือองค์ประกอบแบบโต้ตอบอื่นๆ ที่จะแสดงใต้ข้อความคำอธิบาย โดยปกติประกอบด้วยปุ่มที่อนุญาตให้ผู้ใช้ลองดำเนินการอีกครั้งหรือนำทางไปที่อื่น