コンポーネント

テキスト

基本的なテキストプリミティブ。

すばやい茶色のキツネは、のろまな犬を飛び越えます。
<Text>The quick brown fox jumps over the lazy dog.</Text>

APIリファレンス

このコンポーネントはspan要素に基づいており、共通のマージンプロパティをサポートしています。

プロパティデフォルト
as
"span" | "div" | "label" | "p"
"span"
asChild
boolean
デフォルト値なし
size
Responsive<enum>
デフォルト値なし
weight
Responsive<"light" | "regular" | "medium" | "bold">
デフォルト値なし
align
Responsive<"left" | "center" | "right">
デフォルト値なし
trim
Responsive<"normal" | "start" | "end" | "both">
デフォルト値なし
truncate
boolean
デフォルト値なし
wrap
Responsive<"wrap" | "nowrap" | "pretty" | "balance">
デフォルト値なし
color
enum
デフォルト値なし
highContrast
boolean
デフォルト値なし

別の要素として

asプロパティを使用して、テキストをplabeldiv、またはspanとしてレンダリングします。このプロパティは純粋にセマンティックなものであり、視覚的な外観は変更しません。

これは段落要素です。

これはdiv要素です。
これはspan要素です。
<Text as="p">This is a <Strong>paragraph</Strong> element.</Text>
<Text as="label">This is a <Strong>label</Strong> element.</Text>
<Text as="div">This is a <Strong>div</Strong> element.</Text>
<Text as="span">This is a <Strong>span</Strong> element.</Text>

サイズ

sizeプロパティを使用してテキストサイズを制御します。このプロパティは、正しい行の高さと修正された文字間隔も提供します。テキストサイズが大きくなるにつれて、相対的な行の高さと文字間隔が小さくなります。

すばやい茶色のキツネは、のろまな犬を飛び越えます。すばやい茶色のキツネは、のろまな犬を飛び越えます。すばやい茶色のキツネは、のろまな犬を飛び越えます。すばやい茶色のキツネは、のろまな犬を飛び越えます。すばやい茶色のキツネは、のろまな犬を飛び越えます。すばやい茶色のキツネは、のろまな犬を飛び越えます。すばやい茶色のキツネは、のろまな犬を飛び越えます。すばやい茶色のキツネは、のろまな犬を飛び越えます。すばやい茶色のキツネは、のろまな犬を飛び越えます。
<Flex direction="column" gap="3">
<Text size="1">The quick brown fox jumps over the lazy dog.</Text>
<Text size="2">The quick brown fox jumps over the lazy dog.</Text>
<Text size="3">The quick brown fox jumps over the lazy dog.</Text>
<Text size="4">The quick brown fox jumps over the lazy dog.</Text>
<Text size="5">The quick brown fox jumps over the lazy dog.</Text>
<Text size="6">The quick brown fox jumps over the lazy dog.</Text>
<Text size="7">The quick brown fox jumps over the lazy dog.</Text>
<Text size="8">The quick brown fox jumps over the lazy dog.</Text>
<Text size="9">The quick brown fox jumps over the lazy dog.</Text>
</Flex>

サイズ2~4は、長文コンテンツに適しています。

タイポグラフィの目標は、美しさを最大化し、読みやすく快適にするために、フォントサイズ、行の高さ、行の幅を比例的に関連付けることです。問題は、どの比率が最良の結果をもたらすかということです。黄金比は、美しさと実用性が交差する自然の中でよく観察されます。この「神聖な」比率を使用して、タイポグラフィのこれらの属性を強化できる可能性があります。

タイポグラフィの目標は、美しさを最大化し、読みやすく快適にするために、フォントサイズ、行の高さ、行の幅を比例的に関連付けることです。問題は、どの比率が最良の結果をもたらすかということです。黄金比は、美しさと実用性が交差する自然の中でよく観察されます。この「神聖な」比率を使用して、タイポグラフィのこれらの属性を強化できる可能性があります。

タイポグラフィの目標は、美しさを最大化し、読みやすく快適にするために、フォントサイズ、行の高さ、行の幅を比例的に関連付けることです。問題は、どの比率が最良の結果をもたらすかということです。黄金比は、美しさと実用性が交差する自然の中でよく観察されます。この「神聖な」比率を使用して、タイポグラフィのこれらの属性を強化できる可能性があります。

<Text as="p" mb="5" size="4">
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. The question is: What proportion(s) will give us the best results? The golden ratio is often observed in nature where beauty and utility intersect; perhaps we can use this “divine” proportion to enhance these attributes in our typography.
</Text>
<Text as="p" mb="5" size="3">
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. The question is: What proportion(s) will give us the best results? The golden ratio is often observed in nature where beauty and utility intersect; perhaps we can use this “divine” proportion to enhance these attributes in our typography.
</Text>
<Text as="p" size="2" color="gray">
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. The question is: What proportion(s) will give us the best results? The golden ratio is often observed in nature where beauty and utility intersect; perhaps we can use this “divine” proportion to enhance these attributes in our typography.
</Text>

サイズ1~3は、UIラベルに適しています。

始めましょう数分で次のプロジェクトを開始します
始めましょう数分で次のプロジェクトを開始します
始めましょう数分で次のプロジェクトを開始します
始めましょう数分で次のプロジェクトを開始します
<Grid align="center" columns="2" gap="5" p="3">
<Flex direction="column">
<Text size="3" weight="bold">
Get started
</Text>
<Text color="gray" size="2">
Start your next project in minutes
</Text>
</Flex>
<Flex direction="column">
<Text size="2" weight="bold">
Get started
</Text>
<Text color="gray" size="2">
Start your next project in minutes
</Text>
</Flex>
<Flex direction="column">
<Text size="2" weight="bold">
Get started
</Text>
<Text color="gray" size="1">
Start your next project in minutes
</Text>
</Flex>
<Flex direction="column">
<Text size="1" weight="bold">
Get started
</Text>
<Text color="gray" size="1">
Start your next project in minutes
</Text>
</Flex>
</Grid>

太さ

weightプロパティを使用して、テキストの太さを設定します。

すばやい茶色のキツネは、のろまな犬を飛び越えます。
すばやい茶色のキツネは、のろまな犬を飛び越えます。
すばやい茶色のキツネは、のろまな犬を飛び越えます。
<Text weight="regular" as="div">
The quick brown fox jumps over the lazy dog.
</Text>
<Text weight="medium" as="div">
The quick brown fox jumps over the lazy dog.
</Text>
<Text weight="bold" as="div">
The quick brown fox jumps over the lazy dog.
</Text>

配置

alignプロパティを使用して、テキストの配置を設定します。

左揃え
中央揃え
右揃え
<Text align="left" as="div">Left-aligned</Text>
<Text align="center" as="div">Center-aligned</Text>
<Text align="right" as="div">Right-aligned</Text>

トリム

trimプロパティを使用して、テキストボックスの先頭、末尾、または両側の先頭のスペースをトリムします。

このプロパティは、今後のハーフリーディングコントロール仕様と同様に動作しますが、クロスブラウザサポートのために、一般的なネガティブマージン回避策を内部で使用します。

トリムなしトリムあり
<Flex direction="column" gap="3">
<Text trim="normal" style={{ background: 'var(--gray-a2)', borderTop: '1px dashed var(--gray-a7)', borderBottom: '1px dashed var(--gray-a7)', }} >
Without trim
</Text>
<Text trim="both" style={{ background: 'var(--gray-a2)', borderTop: '1px dashed var(--gray-a7)', borderBottom: '1px dashed var(--gray-a7)', }} >
With trim
</Text>
</Flex>

先頭をトリミングすることは、カードやその他の「箱型」コンポーネントの垂直方向の間隔を調整する際に役立ちます。そうしないと、パディングは上下が側面よりも大きく見えます。

トリムなし

タイポグラフィの目標は、美しさを最大化し、読みやすく快適にするために、フォントサイズ、行の高さ、行の幅を比例的に関連付けることです。

トリムあり

タイポグラフィの目標は、美しさを最大化し、読みやすく快適にするために、フォントサイズ、行の高さ、行の幅を比例的に関連付けることです。
<Flex direction="column" gap="3">
<Box style={{ background: 'var(--gray-a2)', border: '1px dashed var(--gray-a7)', }} p="4" >
<Heading mb="1" size="3">
Without trim
</Heading>
<Text>
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>
</Box>
<Box p="4" style={{ background: 'var(--gray-a2)', border: '1px dashed var(--gray-a7)', }} >
<Heading mb="1" size="3" trim="start">
With trim
</Heading>
<Text trim="end">
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>
</Box>
</Flex>

デフォルトのトリム値は、Radix Themesで使用されるシステムフォントスタック用に構成されています。カスタムフォントを使用している場合は、対応するCSS変数を使用してトリム値を調整できます。

.radix-themes {
--default-leading-trim-start: 0.42em;
--default-leading-trim-end: 0.36em;
--heading-leading-trim-start: 0.42em;
--heading-leading-trim-end: 0.36em;
}

切り捨て

truncateプロパティを使用して、テキストがコンテナからオーバーフローしたときに省略記号でテキストを切り捨てます。

タイポグラフィの目標は、美しさを最大化し、読みやすく快適にするために、フォントサイズ、行の高さ、行の幅を比例的に関連付けることです。
<Flex maxWidth="300px">
<Text truncate>
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>
</Flex>

折り返し

wrapプロパティを使用して、テキストの折り返しを制御します。

タイポグラフィの目標は、美しさを最大化し、読みやすく快適にするために、フォントサイズ、行の高さ、行の幅を比例的に関連付けることです。
<Flex maxWidth="270px">
<Text wrap="nowrap">
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>
</Flex>
タイポグラフィの目標は、美しさを最大化し、読みやすく快適にするために、フォントサイズ、行の高さ、行の幅を比例的に関連付けることです。
<Flex maxWidth="270px">
<Text wrap="balance">
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>
</Flex>
タイポグラフィの目標は、美しさを最大化し、読みやすく快適にするために、フォントサイズ、行の高さ、行の幅を比例的に関連付けることです。
<Flex maxWidth="270px">
<Text wrap="pretty">
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>
</Flex>

text-wrap: prettyは実験的な値であり、 まだすべてのブラウザでサポートされていません。ただし、サポートしているブラウザのプログレッシブエンハンスメントとして扱うことができます。

colorプロパティを使用して、特定のを割り当てます。テキストの色は、一般的な背景色に対して少なくともLc 60 APCAコントラストを達成するように設計されています。

すばやい茶色のキツネは、のろまな犬を飛び越えます。すばやい茶色のキツネは、のろまな犬を飛び越えます。すばやい茶色のキツネは、のろまな犬を飛び越えます。すばやい茶色のキツネは、のろまな犬を飛び越えます。
<Flex direction="column">
<Text color="indigo">The quick brown fox jumps over the lazy dog.</Text>
<Text color="cyan">The quick brown fox jumps over the lazy dog.</Text>
<Text color="orange">The quick brown fox jumps over the lazy dog.</Text>
<Text color="crimson">The quick brown fox jumps over the lazy dog.</Text>
</Flex>

高コントラスト

highContrast プロパティを使用して、背景との色のコントラストを上げることができます。

すばやい茶色の狐はのろまな犬を飛び越える。すばやい茶色の狐はのろまな犬を飛び越える。
<Flex direction="column">
<Text color="gray">The quick brown fox jumps over the lazy dog.</Text>
<Text color="gray" highContrast>
The quick brown fox jumps over the lazy dog.
</Text>
</Flex>

書式設定あり

書式設定コンポーネントを使用して Text を構成し、コンテンツに強調と構造を追加します。

見てください、こんなに役立つリンクイタリック強調、コンピュータのコード、そしてホットキーの組み合わせまで テキスト内の ⇧⌘A

<Text as="p">
Look, such a helpful <Link href="#">link</Link>, an <Em>italic emphasis</Em>,
a piece of computer <Code>code</Code>, and even a hotkey combination{' '}
<Kbd>⇧⌘A</Kbd> within the text.
</Text>

フォームコントロールあり

TextCheckboxRadioGroup、または Switch のようなフォームコントロールと組み合わせて使用すると、テキストが複数行の場合でも、コントロールがテキストの最初の行の中央に自動的に配置されます。

<Box maxWidth="300px">
<Text as="label" size="3">
<Flex gap="2">
<Checkbox defaultChecked /> I understand that these documents are
confidential and cannot be shared with a third party.
</Flex>
</Text>
</Box>