Content and states

Labels and messages explain what is happening and what to do next. Colour and styling support the text.

Practical rules

  • Start action labels with a verb and name the object: “Save article”, “Retry”, “Add project”.
  • Use ol for ordered steps, ul for independent items, and dl for name–value pairs.
  • A field label is always visible. A hint adds detail; a placeholder shows an example. An error explains the next step and is associated with the control.
  • Provide ready, loading, empty and error states. Empty results and errors need different messages and next steps.
  • Preserve input after an error; explain cancellation and action results. Loading blocks repeated actions and sets aria-busy.

Import legato-ui/styles/primitives.css after base.css. Examples and copyable code use the same SFC. Appearance comes from the selected theme.

Labels, lists and action results

Ordered steps, independent items, a visible field label, an associated error and cancellation. Saving works locally.

Before saving

  1. Enter a clear title.
  2. Check it in the material list context.
  3. Save or discard changes.
Name the material's subject, for example Launch plan.

How to name a material

  • A short subject instead of an internal identifier.
  • Clear titles instead of Document 1 and Miscellaneous.
Vue SFC · application example
<script setup lang="ts">
import { WlButton, WlField, WlInput } from "legato-ui";
import { ref } from "vue";
const name = ref("");
const error = ref("");
const message = ref("");
function save(): void {
  error.value = name.value.trim() ? "" : "Enter a material title to continue.";
  message.value = error.value ? "" : "Saved locally: " + name.value.trim();
}
function cancel(): void {
  name.value = "";
  error.value = "";
  message.value = "Changes cancelled.";
}
</script>

<template>
  <div class="wl-stack" data-space="xl">
    <section class="wl-stack" data-space="sm">
      <h3 class="wl-text-subheading">{{ "Before saving" }}</h3>
      <ol class="content-writing-list wl-text-body">
        <li>{{ "Enter a clear title." }}</li>
        <li>{{ "Check it in the material list context." }}</li>
        <li>{{ "Save or discard changes." }}</li>
      </ol>
    </section>
    <form
      class="wl-stack"
      data-space="lg"
      novalidate
      @submit.prevent="save"
    >
      <WlField
        id="content-material-name"
        v-slot="field"
        label="Material title"
        hint="Name the material's subject, for example Launch plan."
        :error="error"
        required
      >
        <WlInput
          :id="field.id"
          v-model="name"
          :invalid="field.invalid"
          :aria-describedby="field.ariaDescribedby"
          required
          placeholder="Launch plan"
        />
      </WlField>
      <div class="wl-inline" data-space="sm">
        <WlButton variant="primary" type="submit">{{ "Save material" }}</WlButton>
        <WlButton @click="cancel">{{ "Discard changes" }}</WlButton>
      </div>
      <p class="wl-text-small wl-text-muted" role="status">{{ message }}</p>
    </form>
    <section class="wl-stack" data-space="sm">
      <h3 class="wl-text-subheading">{{ "How to name a material" }}</h3>
      <ul class="content-writing-list wl-text-body">
        <li>{{ "A short subject instead of an internal identifier." }}</li>
        <li>{{ "Clear titles instead of Document 1 and Miscellaneous." }}</li>
      </ul>
    </section>
  </div>
</template>

<style scoped>
.content-writing-list { display: grid; gap: var(--wl-space-sm); margin: 0; padding-left: var(--wl-space-lg); }
</style>

Ready, loading, empty and error

Switch states, add an example or retry the action. Each state has a message and an action.

Project materials

  • Launch plan
  • Access rules
  • Validation results

Available materials: 3

Local example: states switch without API requests.

Vue SFC · application example
<script setup lang="ts">
import { WlAlert, WlButton, WlEmpty, WlSegmented, WlSkeleton } from "legato-ui";
import { ref } from "vue";
const state = ref<string | null>("ready");
const options = [
  { label: "Done", value: "ready" }, { label: "Loading", value: "loading" },
  { label: "Empty", value: "empty" }, { label: "Error", value: "error" }
];
const materials = ["Launch plan", "Access rules", "Validation results"];
</script>

<template>
  <section class="wl-stack" data-space="lg">
    <WlSegmented
      v-model="state"
      :options="options"
      aria-label="Content example state"
      :pt="{ root: { style: { flexWrap: 'wrap', height: 'auto' } } }"
    />
    <div
      v-if="state === 'loading'"
      class="wl-stack"
      data-space="md"
      role="status"
      aria-busy="true"
    >
      <p class="wl-text-body">{{ "Loading materials…" }}</p>
      <WlSkeleton height="20px" />
      <WlSkeleton height="20px" width="80%" />
      <WlSkeleton height="20px" width="60%" />
    </div>
    <WlEmpty
      v-else-if="state === 'empty'"
      icon="file"
      title="No materials yet"
      description="Add your first material."
    >
      <template #action><WlButton @click="state = 'ready'">{{ "Add example" }}</WlButton></template>
    </WlEmpty>
    <WlAlert v-else-if="state === 'error'" tone="danger" title="Could not load materials">
      {{ "Try again. Your data is preserved." }}
      <template #action><WlButton size="sm" @click="state = 'ready'">{{ "Retry" }}</WlButton></template>
    </WlAlert>
    <div v-else class="wl-stack" data-space="sm">
      <h3 class="wl-text-subheading">{{ "Project materials" }}</h3>
      <ul class="content-state-list wl-text-body"><li v-for="material in materials" :key="material">{{ material }}</li></ul>
      <p class="wl-text-small wl-text-muted" role="status">{{ "Available materials:" }} {{ materials.length }}</p>
    </div>
    <p class="wl-text-small wl-text-muted">{{ "Local example: states switch without API requests." }}</p>
  </section>
</template>

<style scoped>
.content-state-list { display: grid; gap: var(--wl-space-sm); margin: 0; padding-left: var(--wl-space-lg); }
</style>