Skip to content

Empty State

TuiEmpty is used to display a placeholder prompt when a list, container, or page has no content. It typically includes an icon, a descriptive text, and supports adding action buttons to guide users toward the next step.

This component is also reused internally by components like TuiSelect and TuiTree to display states when no matching data is found.

Basic Usage

The simplest usage is to use <TuiEmpty /> directly. By default, it displays a warning icon and a "No Content" prompt.

vue
<template>
  <div class="demo-box">
    <TuiEmpty />
  </div>
</template>

Custom Content

You can customize the icon via the icon property and the prompt text via the text property.

vue
<template>
  <div class="demo-box">
    <TuiEmpty icon="tui-icon ti-star" />
    
    <TuiEmpty text="Your shopping cart is empty" />
  </div>
</template>

Border Appearance

Adding the bordered property adds a border and padding to the component. This style is commonly used inside cards or dropdown menus to make the empty state area more independent and distinct.

vue
<template>
  <div style="width: 300px;">
    <TuiEmpty bordered text="No Data Available" />
  </div>
</template>

Additional Operations

When you need to guide users to move past an empty state (e.g., refresh, retry, or add), you can enable a bottom button via the showButton property and configure its text and click event.

vue
<script setup>
const handleRetry = () => {
  console.log('Retry button clicked')
}
</script>

<template>
  <TuiEmpty 
    bordered 
    showButton 
    buttonText="Refresh and Retry" 
    buttonType="primary"
    :buttonClick="handleRetry" 
  />
</template>

Size

In addition to the default size, it supports small and large sizes to adapt to different layout spaces.

  • small: Suitable for narrow containers such as Select dropdowns or sidebars.
  • large: Suitable for full-page empty states.
vue
<template>
  <div class="row">
    <TuiEmpty size="small" bordered />
    
    <TuiEmpty size="large" bordered />
  </div>
</template>

API Reference

Props

PropertyDescriptionTypeDefault
textPrompt text contentString'暂无内容' (No Content)
iconIcon class nameString'tui-icon ti-alert-circle'
borderedWhether to display border and backgroundBooleanfalse
sizeSize; options include null, 'small', 'large'Stringnull
showButtonWhether to display the bottom action buttonBooleanfalse
buttonTextButton textString'返回' (Back)
buttonTypeButton type; options include 'default', 'primary', 'danger', etc.String'default'
buttonClickCallback function for button clickFunction

Released under the MIT License.