Text
import { Text } from "stylus-ui/Text";
export default () => <Text>The quick brown fox jumps over the lazy dog.</Text>;As another element
Section titled “As another element”Use the as prop to render text as a p, div or span. This prop is purely semantic and does not alter visual appearance.
This text is in a paragraph.
import { Text } from "stylus-ui/Text";
export default () => ( <div className="space-y-2"> <Text as="span">This text is in a span.</Text> <Text as="p">This text is in a paragraph.</Text> <Text as="div">This text is in a div.</Text> </div>);Use the size prop to control text size. This prop also provides correct line height and corrective letter spacing.
import { Text } from "stylus-ui/Text";
export default () => ( <div className="flex flex-col gap-2"> <Text size="xs">The quick brown fox jumps over the lazy dog.</Text> <Text size="sm">The quick brown fox jumps over the lazy dog.</Text> <Text size="md">The quick brown fox jumps over the lazy dog.</Text> <Text size="lg">The quick brown fox jumps over the lazy dog.</Text> <Text size="xl">The quick brown fox jumps over the lazy dog.</Text> </div>);Weight
Section titled “Weight”Use the weight prop to control text thickness.
import { Text } from "stylus-ui/Text";
export default () => ( <div className="flex flex-col gap-2"> <Text weight="normal">The quick brown fox jumps over the lazy dog.</Text> <Text weight="medium">The quick brown fox jumps over the lazy dog.</Text> <Text weight="semibold">The quick brown fox jumps over the lazy dog.</Text> <Text weight="bold">The quick brown fox jumps over the lazy dog.</Text> </div>);Set the color prop to display default text across light and dark mode. If you need secondary text, pass the muted boolean prop to lower the text contrast. All colors meet AA color contrast requirements for common backgrounds.
Change the wrap prop to affect how text flows to multiple lines.
wrapis the default setting and allows text to flow to multiple lines normallynowrapwill prevent text from wrappingprettywill always keep at least two words on the last line of text, to prevent orphansbalancewill run the text block through an algorithm to find the optimally “condensed” paragraph with the least amount of variation in line lengths
import { Text } from "stylus-ui/Text";
export default () => ( <Text wrap="pretty" className="max-w-[320px]"> The goal of typography is to relate font size, line height, and line width in a proportional way that maximizes beauty and makes reading easier and more pleasant. </Text>);When using center aligned text, it can be helpful to combine it with balance:
import { Text } from "stylus-ui/Text";
export default () => ( <Text wrap="balance" size="sm" className="max-w-[320px] text-center"> By signing up, you agree to Scribe's Privacy Policy and Terms of Service. </Text>);Truncate
Section titled “Truncate”Text may be truncated to a specific number of lines by passing a number between 1 and 6 to truncate.
import { Text } from "stylus-ui/Text";
export default () => ( <Text truncate={2} className="max-w-[320px]"> The goal of typography is to relate font size, line height, and line width in a proportional way that maximizes beauty and makes reading easier and more pleasant. </Text>);