Skip to content
Inkoxide

Search covers every page and heading of the docs. Use ↑ ↓ and ↵.

Text

Paragraphs, the runs inside them, and links.

Edit this page

Import them from @inkoxide/react, @inkoxide/vue or @inkoxide/svelte; an Angular template writes them as <ink-text>, <ink-link>. Examples, and how these components work together, are in the guide.

Text

A paragraph, or a run inside one; inside an <Svg>, SVG text (SvgTextProps).

import { Document, Page, Text } from '@inkoxide/react';

export default function Example() {
  return (
    <Document lang="en-US">
      <Page size={[320, 160]} className="p-6">
        <Text className="text-justify leading-relaxed" hyphenate>
          A paragraph is a <Text className="font-bold">Text</Text>, and a Text inside it is a run with its own
          style: <Text className="text-orange-700 italic">a colour</Text>, a weight or a size. Long words are
          hyphenated with the patterns of the document’s language.
        </Text>
      </Page>
    </Document>
  );
}
<script setup lang="ts">
import { Document, Page, Text } from '@inkoxide/vue';
</script>

<template>
  <Document lang="en-US">
    <Page :size="[320, 160]" class="p-6">
      <Text class="text-justify leading-relaxed" hyphenate>
        A paragraph is a <Text class="font-bold">Text</Text>, and a Text inside it is a run with its own
        style: <Text class="text-orange-700 italic">a colour</Text>, a weight or a size. Long words are
        hyphenated with the patterns of the document’s language.
      </Text>
    </Page>
  </Document>
</template>
<script lang="ts">
  import { Document, Page, Text } from '@inkoxide/svelte';
</script>

<Document lang="en-US">
  <Page size={[320, 160]} class="p-6">
    <Text class="text-justify leading-relaxed" hyphenate>
      A paragraph is a <Text class="font-bold">Text</Text>, and a Text inside it is a run with its own
      style: <Text class="text-orange-700 italic">a colour</Text>, a weight or a size. Long words are
      hyphenated with the patterns of the document’s language.
    </Text>
  </Page>
</Document>
import { Component, CUSTOM_ELEMENTS_SCHEMA } from '@angular/core';

@Component({
  selector: 'app-example',
  schemas: [CUSTOM_ELEMENTS_SCHEMA],
  template: `
    <ink-document lang="en-US">
      <ink-page [size]="[320, 160]" class="p-6">
        <ink-text class="text-justify leading-relaxed" hyphenate>
          A paragraph is a <ink-text class="font-bold">Text</ink-text>, and a Text inside it is a run with its own
          style: <ink-text class="text-orange-700 italic">a colour</ink-text>, a weight or a size. Long words are
          hyphenated with the patterns of the document’s language.
        </ink-text>
      </ink-page>
    </ink-document>
  `,
})
export class Example {}
The PDF this example renders.
PropTypeDefaultDescription
roleRoleWhat the text is in tagged output: 'h1'–'h6', 'caption', 'label'…; default a paragraph.
hyphenatebooleanHyphenate this text (same as hyphens-auto). Needs patterns for its language, so set lang on the text or the Document: without one, nothing is hyphenated and a warning says so. false (hyphens-none) also turns off the registered hyphenationCallback.
langstringLanguage of this text, when it differs from the document's.
hyphenationCallbackHyphenationCallback | nullBreaks words where this function says, instead of the built-in patterns (hyphenate), which then leave this text alone. Overrides the registered callback (Font.registerHyphenationCallback); null turns it off for this text, which goes back to hyphenate.
dir'ltr' | 'rtl' | 'auto'Base direction: rtl for Arabic or Hebrew paragraphs, auto from the first strong letter.
orphansnumber1Minimum lines left at the bottom of a page before a break.
widowsnumber1Minimum lines carried to the top of the next page.
hyphenationPenaltynumberHow much textWrap: 'pretty' avoids breaking at a hyphenation point: 0 to 10 000, default 50 (TeX's \hyphenpenalty). Higher values give fewer hyphens and looser lines; 10 000 never breaks a word at one, whatever textWrap. Inherited, and style takes it too.
renderRenderProp
xSvgNumberListWhere the text starts (with textAnchor); a list positions each character.
ySvgNumberList
dxSvgNumberListShifts from where each character would be.
dySvgNumberList
rotateSvgNumberListDegrees each character is turned; the last value repeats.
letterSpacingnumber | string
wordSpacingnumber | string
textDecorationstringunderline, overline, line-through, or several.
textLengthnumber | stringThe width to fit the text to, by its spacing or (lengthAdjust) its glyphs too.
lengthAdjust'spacing' | 'spacingAndGlyphs'
direction'ltr' | 'rtl'
writingMode'horizontal-tb' | 'vertical-rl' | 'vertical-lr' | 'sideways-rl' | 'sideways-lr'The direction of the line: vertical-rl and vertical-lr (the same for one line) go down, sideways-rl down with every character turned, sideways-lr up. Read on the Text.
textOrientation'mixed' | 'upright' | 'sideways'How characters stand in vertical text: mixed (the default) stands CJK upright and turns Latin sideways, upright stands every character, sideways turns every one.
fontFeatureSettingsstringOpenType features, as in CSS: "'tnum', 'liga' off".
fontVariantstringsmall-caps, tabular-nums, no-common-ligatures, … as in CSS.
fontKerning'auto' | 'normal' | 'none'none turns kerning off.

It also takes the shared props break, wrap, minPresenceAhead, fixed, pages, href, bookmark, className, style, id, debug.

A link to href (https://…, mailto:… or #id; src is the same). Inside a Text it is an inline run; elsewhere a box, like a View with href. It adds no colour or underline.

import { Document, Link, Page, Text } from '@inkoxide/react';

export default function Example() {
  return (
    <Document>
      <Page size={[320, 120]} className="p-6">
        <Text>
          Read the{' '}
          <Link href="https://inkoxide.dev/docs" className="text-orange-700 underline">
            documentation
          </Link>
          , or write to{' '}
          <Link href="mailto:[email protected]" className="text-orange-700 underline">
            [email protected]
          </Link>
          .
        </Text>
      </Page>
    </Document>
  );
}
<script setup lang="ts">
import { Document, Link, Page, Text } from '@inkoxide/vue';
</script>

<template>
  <Document>
    <Page :size="[320, 120]" class="p-6">
      <Text>
        Read the
        <Link href="https://inkoxide.dev/docs" class="text-orange-700 underline">
          documentation
        </Link>, or write to
        <Link href="mailto:[email protected]" class="text-orange-700 underline">
          [email protected]
        </Link>.
      </Text>
    </Page>
  </Document>
</template>
<script lang="ts">
  import { Document, Link, Page, Text } from '@inkoxide/svelte';
</script>

<Document>
  <Page size={[320, 120]} class="p-6">
    <Text>
      Read the
      <Link href="https://inkoxide.dev/docs" class="text-orange-700 underline">
        documentation
      </Link>, or write to
      <Link href="mailto:[email protected]" class="text-orange-700 underline">
        [email protected]
      </Link>.
    </Text>
  </Page>
</Document>
import { Component, CUSTOM_ELEMENTS_SCHEMA } from '@angular/core';

@Component({
  selector: 'app-example',
  schemas: [CUSTOM_ELEMENTS_SCHEMA],
  template: `
    <ink-document>
      <ink-page [size]="[320, 120]" class="p-6">
        <ink-text>
          Read the
          <ink-link href="https://inkoxide.dev/docs" class="text-orange-700 underline">
            documentation
          </ink-link>, or write to
          <ink-link href="mailto:[email protected]" class="text-orange-700 underline">
            hello&#64;example.com
          </ink-link>.
        </ink-text>
      </ink-page>
    </ink-document>
  `,
})
export class Example {}
The PDF this example renders.
PropTypeDescription
srcstring

It also takes the shared props break, wrap, minPresenceAhead, fixed, pages, href, bookmark, className, style, id, debug.

Synced from components/text.md in the inkoxide repository.