Skip to content
Primitives

Typography

Text and Title apply the shared type styles while letting you choose the HTML element.

MotionStatic

Install

Install Kineto and follow the theme setup once in your app.

bash
npm install kineto
tsx
import { Text, Title } from "kineto/typography";

Preview

Project settings

Manage your project name and public URL.

tsx
import * as React from "react";
import { cn } from "@/lib/cn";

const textSizes = {
  sm: "text-sm",
  base: "text-base",
  lg: "text-lg",
};

const titleSizes = {
  sm: "text-lg",
  md: "text-2xl",
  lg: "text-3xl sm:text-4xl",
};

const tones = {
  default: "text-foreground",
  muted: "text-muted-foreground",
};

export interface TextProps extends React.HTMLAttributes<HTMLElement> {
  as?: "p" | "span" | "div";
  size?: keyof typeof textSizes;
  tone?: keyof typeof tones;
}

export function Text({ as: Element = "p", size = "base", tone = "default", className, ...props }: TextProps) {
  return <Element className={cn("font-sans", textSizes[size], tones[tone], className)} {...props} />;
}

export interface TitleProps extends React.HTMLAttributes<HTMLHeadingElement> {
  as?: "h1" | "h2" | "h3" | "h4" | "h5" | "h6";
  size?: keyof typeof titleSizes;
}

export function Title({ as: Heading = "h2", size = "md", className, ...props }: TitleProps) {
  return (
    <Heading
      className={cn("font-display font-semibold tracking-tight text-foreground", titleSizes[size], className)}
      {...props}
    />
  );
}

src/components/ui/typography.tsx

Props

PropTypeDefaultDescription
asText: p | span | div. Title: h1–h6Text: p. Title: h2HTML element.
sizeText: sm | base | lg. Title: sm | md | lgText: base. Title: mdVisual size.
tone"default" | "muted""default"Text color. Applies to Text.