Skip to content
CraftDocs
GitHub
Home
Home
Changelog
What's New
Guide
Guide
Getting Started
Principles
Styling Components
Theme System
Foundations
All Tokens
Color
Elevation
Icons
Motion
Shape
Spacing
Typography
Libraries
Libraries
@xds/cli
@xds/core
Themes
Themes
Theme: daily
Default Theme
Theme: matcha
Neutral Theme
Components
Components
AppShell
AspectRatio
Avatar
Avatar
AvatarStatusDot
Badge
Banner
Breadcrumbs
BreadcrumbItem
Breadcrumbs
Button
Button
IconButton
ToggleButton
ToggleButtonGroup
Calendar
Card
Carousel
Chat
ChatComposer
ChatComposerDrawer
ChatComposerInput
ChatComposerTokenElement
ChatDictationButton
ChatLayout
ChatLayoutScrollButton
ChatMessage
ChatMessageBubble
ChatMessageList
ChatMessageMetadata
ChatSendButton
ChatSystemMessage
ChatTokenizedText
ChatToolCalls
Checkbox
CheckboxInput
CheckboxList
CheckboxListItem
ClickableCard
Code
CodeBlock
Collapsible
Collapsible
CollapsibleGroup
useXDSCollapsible
CommandPalette
CommandPalette
CommandPaletteEmpty
CommandPaletteFooter
CommandPaletteGroup
CommandPaletteInput
CommandPaletteItem
CommandPaletteList
DateInput
Dialog
AlertDialog
Dialog
DialogHeader
useXDSImperativeAlertDialog
useXDSImperativeDialog
Divider
DropdownMenu
DropdownMenu
DropdownMenuDivider
DropdownMenuItem
DropdownMenuItemData
DropdownMenuSection
EmptyState
Field
Field
FieldLabel
FieldStatus
Heading
HoverCard
Icon
Kbd
Layout
Center
FormLayout
Grid
GridSpan
HStack
Layout
LayoutContainer
LayoutContent
LayoutFooter
LayoutHeader
LayoutPanel
Section
StackItem
VStack
Link
List
List
ListItem
Markdown
MetadataList
MetadataList
MetadataListItem
MobileNav
MoreMenu
NavIcon
NavMenuItem
NumberInput
OverflowList
Pagination
Popover
PowerSearch
ProgressBar
Radio
RadioList
RadioListItem
Resizable
ResizeHandle
useXDSResizable
SegmentedControl
SegmentedControl
SegmentedControlItem
SelectableCard
Selector
MultiSelector
Selector
SelectorOption
SideNav
SideNav
SideNavCollapseButton
SideNavHeading
SideNavItem
SideNavSection
Skeleton
Slider
Spinner
StatusDot
Switch
Table
BaseTable
Table
TableCell
TableHeaderCell
TableRow
useXDSTableColumnSettings
useXDSTablePagination
useXDSTableSelection
useXDSTableSelectionState
useXDSTableSortable
Tabs
Tab
TabList
TabMenu
Text
TextArea
TextInput
Thumbnail
TimeInput
Timestamp
Toast
Toast
useXDSToast
Token
Tokenizer
Toolbar
Tooltip
TopNav
TopNav
TopNavHeading
TopNavItem
TopNavMegaMenu
TopNavMegaMenuFeaturedCard
TopNavMegaMenuItem
TopNavMenu
TreeList
Typeahead
BaseTypeahead
Typeahead
TypeaheadItem
useXDSHoverCard
useXDSPopover
useXDSTooltip
Utilities
Utilities
LinkProvider
MediaTheme
SyntaxTheme
Theme
useClickableContainer
useEntryAnimation
useFocusTrap
useGridFocus
useImageMode
useInputContainer
useListFocus
useMediaQuery
useOverflow
useScrollLock
useScrollOverflow
useXDSLayer
useXDSStreamingText
Terms of UsePrivacy Policy
Type to search
↑↓Navigate↵SelectEscClose
Text@xds/core v0.0.13 · XDSText

Usage

Text renders styled body text and headings from the theme. Use XDSText with a semantic type for body copy, labels, and captions, and XDSHeading for section titles that output the correct h1–h6 element.
ts
import {XDSText} from '@xds/core/Text'

Best practices

GuidancePractices
DoPick a semantic type (body, label, supporting, large, code) instead of manually setting size and weight — the theme handles the details.
DoSet accessibilityLevel on XDSHeading when the visual level differs from the document outline so screen readers announce the correct hierarchy.
DoUse maxLines with a number to truncate long content — a tooltip appears automatically on hover so no text is lost.
DoEnable hasTabularNumbers for columns of numeric data so digits align vertically across rows.
Don'tOverride size and weight when a semantic type already matches — extra overrides fight the theme and break when themes change.
Don'tSkip heading levels in the document outline — go h1 then h2 then h3, never h1 then h3.
Don'tUse raw HTML tags like <p>, <h1>–<h6>, or <span> for text — XDSText and XDSHeading apply the correct theme tokens automatically.

Sub-components

Text is a compound component with 2 sub-components.

XDSHeading

Semantic heading component that renders h1–h6 elements with themed styling, themed sizing via type scale tokens, and line-clamp truncation.
PropTypeDescription
levelrequired
1 | 2 | 3 | 4 | 5 | 6Visual heading level. Determines both the HTML element (h1–h6) and the styling from the theme.
childrenrequired
ReactNodeHeading content.
accessibilityLevel
1 | 2 | 3 | 4 | 5 | 6Accessibility level override. When set and different from `level`, applies `aria-level` so the document outline differs from the visual style.
color
'primary' | 'secondary' | 'disabled' | 'placeholder' | 'active' | 'inherit' (default: 'primary')Text color.
display
'inline' | 'block' (default: 'block')Display type. Silently overridden to 'block' when maxLines > 0 or hasCapsize is true.
maxLines
number (default: 0)Maximum lines before truncation. 0 means no truncation. When set, shows a tooltip on hover if content is truncated.
hasTruncateTooltip
boolean | LayerPlacement (default: true)Controls tooltip behavior for truncated text. true shows the tooltip at the default position, false disables it, or a LayerPlacement string sets a specific position.
wordBreak
'break-word' | 'break-all'Word break behavior when truncating. Defaults to 'break-all' for single-line truncation, 'break-word' otherwise.
textWrap
'wrap' | 'nowrap' | 'balance' | 'pretty'Text wrapping behavior.
hasCapsize
boolean (default: false)Enable optical alignment using text-box-trim. Forces block display.
hasStrikethrough
boolean (default: false)Apply strikethrough text decoration.
id
stringHTML id attribute.

XDSText

Semantic body text component that renders text with type-based styling from the theme, with optional truncation, decoration, and layout props.
PropTypeDescription
childrenrequired
ReactNodeText content.
type
'body' | 'large' | 'label' | 'supporting' | 'code' (default: 'body')Semantic text type. Determines size, weight, and line-height from the theme.
size
'4xs' | '3xs' | '2xs' | 'xsm' | 'sm' | 'base' | 'lg' | 'xl' | '2xl' | '3xl' | '4xl'Explicit font size override. Overrides the size from `type` but preserves other type properties. Prefer using `type` alone.
color
'primary' | 'secondary' | 'disabled' | 'placeholder' | 'active' | 'inherit'Text color. Defaults to 'secondary' for the 'supporting' type, 'primary' for all others.
weight
'normal' | 'medium' | 'semibold' | 'bold'Font weight override.
display
'inline' | 'block' (default: 'inline')Display type. Silently overridden to 'block' when maxLines > 0 or hasCapsize is true.
as
'span' | 'p' | 'div' | 'label' (default: 'span')HTML element to render.
maxLines
number (default: 0)Maximum lines before truncation. 0 means no truncation. When set, shows a tooltip on hover if content is truncated.
hasTruncateTooltip
boolean | LayerPlacement (default: true)Controls tooltip behavior for truncated text. true shows the tooltip at the default position, false disables it, or a LayerPlacement string sets a specific position.
wordBreak
'break-word' | 'break-all'Word break behavior when truncating. Defaults to 'break-all' for single-line truncation, 'break-word' otherwise.
textWrap
'wrap' | 'nowrap' | 'balance' | 'pretty'Text wrapping behavior.
hasCapsize
boolean (default: false)Enable optical alignment using text-box-trim. Forces block display.
hasStrikethrough
boolean (default: false)Apply strikethrough text decoration.
hasTabularNumbers
boolean (default: false)Use tabular (monospace) numbers for aligned numeric data.
id
stringHTML id attribute.
xstyle
StyleXStylesStyleX styles for layout customization (margins, positioning, sizing). Must be a stylex.create() value — not an inline style object like style={{}}.

Examples

Common configurations, variations, and states.
Text — Colors
All text color options (primary, secondary, disabled, placeholder, active) applied to body text to show their intended use.
Text — Heading Levels
All 6 heading levels (h1 through h6) rendered with XDSHeading to show the full type scale.
Text — Inline
Mixing body and code text inline within a single line using the default inline display mode.
Text — Truncation
Single-line and multi-line text truncation with ellipsis using maxLines in a width-constrained container.
Text — Types
All 5 semantic text types (body, large, label, supporting, code) with their default styling from the theme.
Text — Weight
The 4 font weight variants (normal, medium, semibold, bold) applied to body text.
Text — Word Break
Compares break-word and break-all word break modes on a long unbreakable string.
Text — Wrap
The 4 text-wrap modes (wrap, nowrap, balance, pretty) shown in width-constrained containers.