Text

Running text as a span, div, label or paragraph, set on the theme's body scale, and in the size, weight and colour around it by default.

Content goes here.
import { Text } from "@produkto/ui/Text";

const Example = () => <Text>Content goes here.</Text>;

export default Example;

Usage

import { Text } from "@produkto/ui/Text";
<Text as="p" size="sm" weight="medium">
  Content goes here.
</Text>

Examples

Sizes

size steps through the body scale from xs to 5xl, and without it the text keeps the size around it.

Content goes here.Content goes here.Content goes here.Content goes here.Content goes here.Content goes here.Content goes here.Content goes here.Content goes here.
import { Text, type TextSize } from "@produkto/ui/Text";

const sizes: TextSize[] = [
  "xs",
  "sm",
  "base",
  "lg",
  "xl",
  "2xl",
  "3xl",
  "4xl",
  "5xl",
];

const Example = () => (
  <div className="flex flex-col gap-2">
    {sizes.map((size) => (
      <Text key={size} size={size}>
        Content goes here.
      </Text>
    ))}
  </div>
);

export default Example;

Weights

weight sets the text normal, medium or semibold, the kit's three weights, and without it the text keeps the weight around it.

Content goes here.Content goes here.Content goes here.
import { Text, type TextWeight } from "@produkto/ui/Text";

const weights: TextWeight[] = ["normal", "medium", "semibold"];

const Example = () => (
  <div className="flex flex-col gap-2">
    {weights.map((weight) => (
      <Text key={weight} weight={weight}>
        Content goes here.
      </Text>
    ))}
  </div>
);

export default Example;

Align

align sets the text at the start, the centre or the end of its box, and without it the text keeps the alignment around it, the start in running text.

Content goes here.Content goes here.Content goes here.
import { Text, type TextAlign } from "@produkto/ui/Text";

const aligns: TextAlign[] = ["start", "center", "end"];

const Example = () => (
  <div className="flex w-full max-w-xs flex-col gap-2">
    {aligns.map((align) => (
      <Text align={align} key={align}>
        Content goes here.
      </Text>
    ))}
  </div>
);

export default Example;

Truncate

truncate keeps the text to one line and ends it with an ellipsis where it overflows, beside text that wraps as it does by default.

Content goes here. Content goes here. Content goes here. Content goes here.Content goes here. Content goes here. Content goes here. Content goes here.
import { Text } from "@produkto/ui/Text";

const content: string =
  "Content goes here. Content goes here. Content goes here. Content goes here.";

const Example = () => (
  <div className="flex w-full max-w-xs flex-col gap-4">
    <Text>{content}</Text>
    <Text truncate>{content}</Text>
  </div>
);

export default Example;

Muted

muted writes the text in the muted grey, for the quieter details around a title, beside text in the colour around it as it is by default.

Content goes here.Content goes here.
import { Text } from "@produkto/ui/Text";

const Example = () => (
  <div className="flex flex-col gap-2">
    <Text>Content goes here.</Text>
    <Text muted>Content goes here.</Text>
  </div>
);

export default Example;

As

as renders a p, label or div in place of the span it is by default, which changes the markup and leaves the look alone.

Content goes here, in a span.

Content goes here, in a p.

Content goes here, in a div.
import { Text } from "@produkto/ui/Text";

const Example = () => (
  <div className="flex flex-col gap-2">
    <Text>Content goes here, in a span.</Text>
    <Text as="p">Content goes here, in a p.</Text>
    <Text as="label">Content goes here, in a label.</Text>
    <Text as="div">Content goes here, in a div.</Text>
  </div>
);

export default Example;

API Reference

Text

TextProps · components/Text/Text.types.ts
PropTypeDefault
asChildbooleanfalse
sizeTextSize"xs" | "sm" | "base" | "lg" | "xl" | "2xl" | "3xl" | "4xl" | "5xl"-
weightTextWeight"normal" | "medium" | "semibold"-
alignTextAlign"start" | "center" | "end"-
truncateboolean-
mutedboolean-
as"span" | "div" | "label" | "p""span"

It also takes the props of <span>, <div>, <label>, <p>.