konstantin-paulus 7372c40429 Update documentation references and refactor knowledge handling
- Changed references from `knowledge` to `docs` in README and various files to reflect the new documentation structure.
- Updated `.gitignore` to exclude the `docs` directory instead of `knowledge`.
- Refactored `forge.config.ts` and `main.ts` to utilize the new `docs` directory for staging resources.
- Introduced `stage-docs.mjs` script to manage the staging of documentation files.
- Added new documentation files under `docs/`, including `INSTRUCTIONS.md`, brand guidelines, and design specifications.
- Removed outdated `knowledge` related tests and files to streamline the codebase.
2026-09-11 20:33:57 +02:00

54 lines
3.5 KiB
Markdown
Raw Permalink Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

# `<text>`
A text node; its children are the glyphs.
```tsx
<text color="#FFFFFF" fontSize={128} fontWeight="bold" width={1920} textAlign="center">
Hello World
</text>
```
A `<text>` given neither `width` nor `height` **sizes itself to what it says**; giving it either fixes the box, wraps into it, and makes `textAlign` / `textBaseline` mean something. A centered full-frame title is `<text width={1920} height={1080} textAlign="center" textBaseline="middle">…</text>`.
## Props
All [common props](./elements.md#common-props), plus:
| Prop | Type | Default | Meaning |
| ---- | ---- | ------- | ------- |
| children | `string` (or expressions resolving to strings) | **required** | The text content, alongside any `<textRange>`, paint, `<stroke>`, `<shadow>`, `<effect>`, `<animation>` and `<keyframeTrack>` children. |
| `color` | `string` | none | The glyph color; any CSS color, alpha ignored (use `opacity`). Drawn beneath any paint children (see [paints.md](./paints.md)); animate it with a `color` [keyframe track](./keyframes.md). A text with neither `color` nor a paint child draws no glyphs. |
| `fontFamily` | `string` | `Inter` | A family available on the machine ([`fonts`](../tools/fonts.md)); see [fonts.md](./fonts.md). |
| `fontSize` | `number` | `16` | Px. |
| `fontWeight` | `number \| "normal" \| "bold"` | `"normal"` | CSS weights `100`–`900`. |
| `fontStyle` | `"normal" \| "italic" \| "oblique"` | `"normal"` | |
| `letterSpacing` | `number` | `0` | Extra space between glyphs, px; negative tightens. |
| `textCase` | `"original" \| "upper" \| "lower"` | `"original"` | Casing applied when drawing; the text itself stays as written. |
| `textAlign` | `"left" \| "center" \| "right"` | `"left"` | Horizontal alignment of glyphs within the box. |
| `textBaseline` | `"top" \| "middle" \| "bottom" \| "alphabetic"` | `"top"` | Vertical alignment within the box: the block anchored to the top or bottom, centered, or (`"alphabetic"`) the first line's baseline at the top of the box. |
| `leading` | `number` | `1` | Line height as a multiple of each line's natural height. |
The text-only [animation types](./animations.md) (`"appearWord"`, `"appearChar"`, `"scramble"`) animate the glyphs themselves.
## `<textRange>`
A style override for a run of the glyphs, a sub-entity like a paint: `start`/`end` address the run by character index into the text as written (before `textCase`), and the rest is what changes inside it. An unset font prop inherits the text's; its own `color`, paints, strokes and shadows replace the text's for those glyphs. Several stack in document order, later ones winning where they overlap. Layout (`textAlign`, `textBaseline`, `leading`) stays the text's.
```tsx
<text fontSize={96} color="#FFFFFF" width={1920} textAlign="center">
Ship it today
<textRange start={5} end={7} color="#F43F5E" fontWeight="bold" />
<textRange start={8} fontStyle="italic" letterSpacing={2}>
<stroke color="#000000" width={2} />
</textRange>
</text>
```
| Prop | Type | Default | Meaning |
| ---- | ---- | ------- | ------- |
| `start` | `number` | **required** | First character of the run, 0-based. |
| `end` | `number` | end of text | One past the last character of the run. |
| `color` | `string` | inherits | The run's glyph color; any CSS color. |
| `fontFamily`, `fontSize`, `fontWeight`, `fontStyle`, `letterSpacing`, `textCase` | as on `<text>` | inherit | Font overrides for the run. |
| children | | | Paint, `<stroke>`, `<shadow>` and `<keyframeTrack>` (a `color` track) children. |