Typography

HTML defines text structure; CSS classes define its appearance. Fonts and sizes come from the theme.

Practical rules

  • Use one page heading; h1–h6 levels follow the document structure. Choose the text role separately from the HTML tag.
  • Body is for main text; small + text-muted is for descriptions. Check that required instructions are readable on the selected background.
  • Keep long lines to roughly 60–75 characters. On small screens, wrap text and use title instead of display when needed.
  • Label names an action or field; code shows an identifier or code fragment. Do not replace a label with a placeholder.
  • Use theme fonts. Legato, Legato Dark, Classic and Classic Dark share the same components and use different token values.

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

Text roles

Eight text roles using wl-text-* classes in the selected theme.

wl-text-displayMain introductory heading; one per screen.

Display

wl-text-titlePage and large dialog title.

Page title

wl-text-headingPage section and independent block.

Section heading

wl-text-subheadingCard, field group or small dialog.

Block heading

wl-text-bodyDescriptions, instructions and form text.

Body text

wl-text-smallCaptions and supporting text.

Small text

wl-text-labelShort action or field label.

Label

wl-text-codeTokens, identifiers and technical values.

Code and data

The group already has larger semantic text values. Enable wl-type-scale to apply them to the components. Without it, the 1.0 component sizes stay in place; small Segmented already follows the small-size role. Control uses the control size and label line height, weight and family. Local component tokens can override an individual role.

Component text roles
Component tokenDefault font sizewl-type-scale
--wl-card-title-*14pxsubheading
--wl-card-subtitle-*12.5pxsmall
--wl-card-content-*13.5pxbody
--wl-accordion-title-*13.5pxcontrol / label
--wl-accordion-body-*13pxbody
--wl-alert-*13pxbody
--wl-alert-title-*inheritsubheading
--wl-segmented-*13pxcontrol / label
--wl-select-font-size13.5pxcontrol
--wl-select-option-font-size13.5pxcontrol
--wl-select-sm-font-size12.5px12.5px
--wl-select-lg-font-size14.5px14.5px
--wl-select-message-font-size13pxsmall
--wl-multiselect-chip-font-size12pxsmall
Field labels follow the label role, hints use small and tab labels use control. Use rem for a role that should follow the reader's font size.
Team guide
Updated October 1
Team structure, roles and agreements.
Team guide
Team structure, roles and agreements.
Team guide
Team structure, roles and agreements.

Open a list to compare its text with the field. Both lists open in body. This example passes the same class and scale values to pt.overlay so the local settings reach the options.

Draft
Vue SFC · application example
<script setup lang="ts">
import { WlAccordion, WlAlert, WlCard, WlCheckbox, WlField, WlInput, WlMultiSelect, WlSegmented, WlSelect, wlTypography } from "legato-ui";
import { computed, ref } from "vue";
const semantic = ref(false);
const choice = ref<"draft" | "published" | null>("draft");
const status = ref<"draft" | "published" | null>(null);
const statuses = ref<("draft" | "published")[]>(["draft"]);
const scale = {
  "--wl-type-body-size": "1.125rem", "--wl-type-body-line-height": "28px",
  "--wl-type-subheading-size": "22px", "--wl-type-subheading-line-height": "30px",
  "--wl-type-control-size": "1.125rem", "--wl-type-small-size": ".875rem",
  "--wl-type-small-line-height": "22px", "--wl-type-label-line-height": "26px"
};
const selectPanel = computed(() => semantic.value ? { overlay: { class: "wl-type-scale", style: scale } } : undefined);
const mappings = [
  ["card-title-*", "14px", "subheading"], ["card-subtitle-*", "12.5px", "small"], ["card-content-*", "13.5px", "body"],
  ["accordion-title-*", "13.5px", "control / label"], ["accordion-body-*", "13px", "body"],
  ["alert-*", "13px", "body"], ["alert-title-*", "inherit", "subheading"], ["segmented-*", "13px", "control / label"],
  ["select-font-size", "13.5px", "control"], ["select-option-font-size", "13.5px", "control"],
  ["select-sm-font-size", "12.5px", "12.5px"], ["select-lg-font-size", "14.5px", "14.5px"],
  ["select-message-font-size", "13px", "small"], ["multiselect-chip-font-size", "12px", "small"]
];
const items = computed(() => [{
  key: "one", title: "Team guide", content: "Team structure, roles and agreements."
}]);
const options = computed(() => [
  { value: "draft" as const, label: "Draft" },
  { value: "published" as const, label: "Published" }
]);
const roleText = {
  display: { label: "Display", description: "Main introductory heading; one per screen." },
  title: { label: "Page title", description: "Page and large dialog title." },
  heading: { label: "Section heading", description: "Page section and independent block." },
  subheading: { label: "Block heading", description: "Card, field group or small dialog." },
  body: { label: "Body text", description: "Descriptions, instructions and form text." },
  small: { label: "Small text", description: "Captions and supporting text." },
  label: { label: "Label", description: "Short action or field label." },
  code: { label: "Code and data", description: "Tokens, identifiers and technical values." }
};
</script>

<template>
  <section class="wl-stack" data-space="xl">
    <dl class="typography-example wl-stack" data-space="lg">
      <div v-for="role in wlTypography" :key="role.name" class="typography-example-role">
        <dt class="wl-stack" data-space="xs">
          <code class="wl-text-code">{{ 'wl-text-' + role.name }}</code>
          <span class="wl-text-small wl-text-muted">{{ roleText[role.name].description }}</span>
        </dt>
        <dd><p :class="'wl-text-' + role.name">{{ roleText[role.name].label }}</p></dd>
      </div>
    </dl>
    <WlCheckbox v-model="semantic">{{ "Use semantic component typography (wl-type-scale)" }}</WlCheckbox>
    <p class="wl-text-small">{{ "The group already has larger semantic text values. Enable wl-type-scale to apply them to the components. Without it, the 1.0 component sizes stay in place; small Segmented already follows the small-size role. Control uses the control size and label line height, weight and family. Local component tokens can override an individual role." }}</p>
    <table class="typography-role-map">
      <caption>{{ "Component text roles" }}</caption>
      <thead><tr>
        <th scope="col">{{ "Component token" }}</th>
        <th scope="col">{{ "Default font size" }}</th>
        <th scope="col">wl-type-scale</th>
      </tr></thead>
      <tbody><tr v-for="[token, size, role] in mappings" :key="token">
        <th scope="row"><code>--wl-{{ token }}</code></th>
        <td>{{ size }}</td><td><code>{{ role }}</code></td>
      </tr></tbody>
    </table>
    <div
      class="wl-stack"
      :class="{ 'wl-type-scale': semantic }"
      :style="scale"
      data-space="md"
      data-testid="semantic-component-example"
    >
      <WlField v-slot="field" label="Choose a status" hint="Field labels follow the label role, hints use small and tab labels use control. Use rem for a role that should follow the reader's font size.">
        <WlInput :id="field.id" :aria-describedby="field.ariaDescribedby" />
      </WlField>
      <WlCard>
        <template #title>{{ "Team guide" }}</template>
        <template #subtitle>{{ "Updated October 1" }}</template>
        {{ "Team structure, roles and agreements." }}
      </WlCard>
      <WlAccordion :items="items" :default-open-keys="['one']" />
      <WlAlert title="Team guide">{{ "Team structure, roles and agreements." }}</WlAlert>
      <p class="wl-text-small">{{ "Open a list to compare its text with the field. Both lists open in body. This example passes the same class and scale values to pt.overlay so the local settings reach the options." }}</p>
      <WlSelect
        v-model="status"
        :options="options"
        option-label="label"
        option-value="value"
        placeholder="Choose a status"
        aria-label="Choose a status"
        :pt="selectPanel"
      />
      <WlMultiSelect
        v-model="statuses"
        :options="options"
        option-label="label"
        option-value="value"
        display="chip"
        aria-label="Selected statuses"
        :pt="selectPanel"
      />
      <WlSegmented
        v-for="size in (['sm', 'md', 'lg'] as const)"
        :key="size"
        v-model="choice"
        :size="size"
        :options="options"
        :aria-label="'Segmented ' + size"
      />
    </div>
  </section>
</template>

<style scoped>
.typography-example { margin: 0; }
.typography-role-map { border-collapse: collapse; width: 100%; overflow-wrap: anywhere; text-align: start; }
.typography-role-map :where(th, td) { padding: var(--wl-space-sm); border-bottom: 1px solid var(--wl-border); text-align: start; }
.typography-example-role {
  display: grid;
  grid-template-columns: minmax(0, 180px) minmax(0, 1fr);
  gap: var(--wl-space-lg);
  padding-bottom: var(--wl-space-lg);
  border-bottom: 1px solid var(--wl-border);
  overflow-wrap: anywhere;
}
.typography-example-role:last-child { padding-bottom: 0; border-bottom: 0; }
.typography-example-role dd { min-width: 0; margin: 0; }
@media (max-width: 640px) { .typography-example-role { grid-template-columns: minmax(0, 1fr); gap: var(--wl-space-sm); } }
</style>

Headings, body text and descriptions

Hierarchy for articles, short instructions and name–value pairs. Choose HTML levels for the page context.

Working materials · October 3

Launch preparation

Before publishing, check the project settings and assign an owner. The heading explains the subject; the body text explains the next step.

Project access

Members receive permissions through a group project-editors.

Changing permissions does not affect previously saved materials.

Owner
Anna Petrova
Status
Ready for review
Vue SFC · application example
<script setup lang="ts">
</script>

<template>
  <article class="hierarchy-example wl-stack" data-space="lg">
    <header class="wl-stack" data-space="sm">
      <p class="wl-text-small wl-text-muted">{{ "Working materials · October 3" }}</p>
      <h3 class="wl-text-heading">{{ "Launch preparation" }}</h3>
      <p class="wl-text-body">{{ "Before publishing, check the project settings and assign an owner. The heading explains the subject; the body text explains the next step." }}</p>
    </header>
    <section class="wl-stack" data-space="sm">
      <h4 class="wl-text-subheading">{{ "Project access" }}</h4>
      <p class="wl-text-body">
        {{ "Members receive permissions through a group" }} <code class="wl-text-code">project-editors</code>.
      </p>
      <p class="wl-text-small wl-text-muted">{{ "Changing permissions does not affect previously saved materials." }}</p>
    </section>
    <dl class="hierarchy-example-meta">
      <div>
        <dt class="wl-text-label">{{ "Owner" }}</dt>
        <dd class="wl-text-body">{{ "Anna Petrova" }}</dd>
      </div>
      <div>
        <dt class="wl-text-label">{{ "Status" }}</dt>
        <dd class="wl-text-body">{{ "Ready for review" }}</dd>
      </div>
    </dl>
  </article>
</template>

<style scoped>
.hierarchy-example { max-width: 65ch; overflow-wrap: anywhere; }
.hierarchy-example-meta { display: grid; gap: var(--wl-space-md); margin: 0; }
.hierarchy-example-meta dd { margin: var(--wl-space-xs) 0 0; }
</style>