Text
The general-purpose type element: size, weight, color, family, line height and alignment are all attributes mapped to design tokens. It carries no document semantics — it is not a heading, a paragraph or a list, even when styled like one.
Code
<kb-stack direction="column" spacing="nano" align="start">
<kb-text size="lg" weight="bold">Monthly summary</kb-text>
<kb-text size="xs">Everything that happened in your account this month.</kb-text>
<kb-text size="xxxs" color="master">Updated 2 minutes ago</kb-text>
</kb-stack>Usage
<kb-text size="xs" color="master-dark" weight="regular">Hello world</kb-text>When to use
- Body copy and inline text anywhere, when it should follow the type scale rather than the browser's defaults.
- A visual heading inside a component — a card title, a section title — where size and weight matter and the document outline doesn't.
- Text that shifts by token — a muted caption, a bold total — without writing CSS per instance.
When not to use
- A document heading. A screen reader's heading navigation needs a real
<h1>–<h6>. Use one and style it, or nest akb-textinside it. - A field label or hint —
<kb-label>and<kb-helper>exist so the form vocabulary stays uniform and self-slotting. - Long-form prose with multiple paragraphs — this renders one inline box with no paragraph spacing; use real
<p>elements inside a<kb-stack>.
Composition
- Can contain: text and inline markup — the shadow root is a single unnamed
<slot>. Nested<a>,<strong>or a<kb-icon>inherit the color and size set here. One or more<kb-on>children add arcs beyond the singleonattribute. - Can be a child of: anything. The host has no
displayof its own, so it behaves as inline content and participates in whatever flex or grid context surrounds it.
Code
<kb-text size="xs">
Read the <a href="#/learn/quick-start">quick start</a> to see it working.
</kb-text>Size
size steps the shared type scale. Pick by role, not by how large it looks in one layout.
Code
<kb-stack direction="column" spacing="quarck" align="start">
<kb-text size="xxxs">xxxs — captions, metadata</kb-text>
<kb-text size="xxs">xxs — the default</kb-text>
<kb-text size="xs">xs — body copy</kb-text>
<kb-text size="md">md — component titles</kb-text>
<kb-text size="xl">xl — page titles</kb-text>
</kb-stack>size | Renders at | Use for |
|---|---|---|
xxxs / xxs | 12 / 14px | Captions, metadata, dense cells. xxs is the default. |
xs / sm | 16 / 20px | Body copy and lead paragraphs. |
md / lg | 24 / 32px | Component and section titles. |
xl–xxxl | 40–64px | Page titles. |
display / giant | 80 / 96px | Marketing headlines only — these break small screens. |
weight has three steps (regular, medium, bold) and line-height runs default (100%) through xxl (200%). Tighter line heights suit large display type; body copy wants lg or xl.
Color
color accepts any suffix of --color-* as a closed keyword set. Use the semantic families for meaning, the neutral master-* ramp for hierarchy.
Code
<kb-stack direction="column" spacing="quarck" align="start">
<kb-text color="master-dark">master-dark — body text</kb-text>
<kb-text color="master">master — secondary</kb-text>
<kb-text color="primary">primary — brand emphasis</kb-text>
<kb-text color="success">success — positive outcome</kb-text>
<kb-text color="danger">danger — error or destructive</kb-text>
</kb-stack>A keyword outside the set is ignored: the attribute change never reaches the property, which keeps its last valid value (master-dark until you set one) — check the token name if a color "doesn't apply". The same holds for size, weight, family, line-height and align.
Attributes
| Attribute | Type | Default | Description |
|---|---|---|---|
size | token step | xxs | Type size, resolved against --font-size-{value}. |
weight | regular | medium | bold | regular | Resolved against --font-weight-{value}. |
color | token suffix | master-dark | Resolved against --color-{value}. |
family | base | highlight | base | Resolved against --font-family-{value}. |
line-height | token step | lg | Resolved against --line-height-{value}. |
align | left | center | right | justify | left | Text alignment. |
on | arc string | — | Echo wiring, source/event:type/sink — lets another element drive an attribute of this text. |
This element dispatches no events; on only ever receives.
Styling
The attributes cover per-instance cases. The --text-* properties exist for the surface-level override — a whole panel shifting its type — and for values the scale doesn't express, like tracking.
| Custom property | Default | Controls |
|---|---|---|
--text-color | var(--color-{color}) | Color, overriding the attribute. |
--text-font-family | var(--font-family-{family}) | Type family. |
--text-font-size | var(--font-size-{size}) | Type size. |
--text-font-weight | var(--font-weight-{weight}) | Type weight. |
--text-line-height | var(--line-height-{lineHeight}) | Line height. |
--text-letter-spacing | 0.38px | Tracking — the one value with no attribute. |
Prefer the attribute for one element; reach for the property when a rule should apply to many:
.panel-dark kb-text {
--text-color: var(--color-pure-white);
}States and accessibility
- The element exposes no role. Styling it at
displaysize does not make it a heading — pair it with a real heading element, orrole="heading"plusaria-level, when it introduces a section. - Watch contrast moving down the
master-*ramp:master-lighton white is decorative-grade, not body-text grade. - Don't let color be the only carrier of meaning — a
danger-colored total needs words that say what's wrong. align="justify"produces uneven word spacing in narrow columns; keep it for wide measures.
Do's and don'ts
| Do | Don't |
|---|---|
Pick size by the role of the text | Pick it by how big it looks in one layout |
| Wrap or nest a real heading element for structure | Use size="xxxl" and call it a heading |
Use <kb-label> / <kb-helper> inside form fields | Recreate them with kb-text and per-instance attributes |
Set --text-* on an ancestor to shift a whole surface | Repeat the same attribute override on every element |