Skip to Content
Font Size

Font Size

Use fontSize prop to control the font-size of an element.

Name

Styles

xs
sm
md
lg
xl
2xl
3xl
4xl
inherit

Documentation

sm

The quick brown fox jumps over the lazy dog.

md

The quick brown fox jumps over the lazy dog.

lg

The quick brown fox jumps over the lazy dog.

xl

The quick brown fox jumps over the lazy dog.

2xl

The quick brown fox jumps over the lazy dog.

import type { ComponentPropsWithoutRef } from "react"; import { Group, Text } from "@optiaxiom/react"; export function App() { return ( <Group flexDirection="column" gap="16"> <DemoItem fontSize="sm"> The quick brown fox jumps over the lazy dog. </DemoItem> <DemoItem fontSize="md"> The quick brown fox jumps over the lazy dog. </DemoItem> <DemoItem fontSize="lg"> The quick brown fox jumps over the lazy dog. </DemoItem> <DemoItem fontSize="xl"> The quick brown fox jumps over the lazy dog. </DemoItem> <DemoItem fontSize="2xl"> The quick brown fox jumps over the lazy dog. </DemoItem> </Group> ); } function DemoItem({ children, fontSize, }: Pick<ComponentPropsWithoutRef<typeof Text>, "children"> & { fontSize: Extract<ComponentPropsWithoutRef<typeof Text>["fontSize"], string>; }) { return ( <div> <Text color="fg.tertiary" fontFamily="mono" fontWeight="600"> {fontSize} </Text> <Text fontSize={fontSize}>{children}</Text> </div> ); }

Pass an object or array to change the font size per breakpoint. Read the Responsive Styles guide for the notation.

import { Text } from "@optiaxiom/react"; export function App() { return ( <Text fontSize={["md", "xl"]}> The quick brown fox jumps over the lazy dog. </Text> ); }

A

a

Typography

The type scale, and which component renders each style. Start here before reaching for font props.

Last updated on