Components › Components

On this page

Empty

What to show when there is nothing yet, with a way to start.

No projects yet

Create a project to start tracking work.

Usage #

tscl
@import uiEmpty from './empty.tscl'
@import uiButton from './button.tscl'

<div class="demo">
  <uiEmpty>
    @slot('icon') {
      <svg width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2">
        <path d="M3 7h18M3 12h18M3 17h10" />
      </svg>
    }
    @slot('title') {
      No projects yet
    }
    Create a project to start tracking work.
    @slot('action') {
      <uiButton>New project</uiButton>
    }
  </uiEmpty>
</div>

<style scoped>
  :scope {
    display: grid;
    gap: 12px;
    padding: 24px;
    border: 1px solid var(--ui-border);
    border-radius: var(--ui-radius);
    background: var(--ui-bg);
    color: var(--ui-fg);
  }
</style>

Source #

Copy it next to your components as empty.tscl.

tscl
{{-- Empty: what to show when there's nothing yet: an icon, a title, a line of help, and an action. --}}

<div data-part="empty">
  <div aria-hidden="true" data-part="empty-icon"><slot name="icon" /></div>
  <p data-part="empty-title"><slot name="title" /></p>
  <div data-part="empty-description"><slot /></div>
  <div data-part="empty-action"><slot name="action" /></div>
</div>

<style scoped>
  @layer theme, base, components, utilities;
  @layer components {
    :where(:scope) {
      display: grid;
      justify-items: center;
      gap: 8px;
      padding: 32px 16px;
      border: 1px dashed var(--ui-border);
      border-radius: var(--ui-radius);
      color: var(--ui-fg);
      font-family: var(--ui-font);
      text-align: center;
    }
    :where([data-part='empty-icon']) {
      display: grid;
      place-items: center;
      width: 48px;
      height: 48px;
      border-radius: 50%;
      background: var(--ui-muted-bg);
      color: var(--ui-muted);
    }
    :where([data-part='empty-title']) {
      margin: 0;
      font: 600 calc(var(--ui-font-size) + 2px) var(--ui-font-heading);
    }
    :where([data-part='empty-description']) {
      max-width: 40ch;
      color: var(--ui-muted);
    }
    :where([data-part='empty-icon']:empty),
    :where([data-part='empty-title']:empty),
    :where([data-part='empty-description']:empty),
    :where([data-part='empty-action']:empty) {
      display: none;
    }
  }
</style>

Styling #

Needs #