design-system
Compare original and translation side by side
🇺🇸
Original
English🇨🇳
Translation
ChineseLayout and Text Primitives at Sentry
Sentry的布局与文本原语
Core Principle
核心原则
ALWAYS use core components from instead of creating styled components with Emotion.
@sentry/scrapsCore components provide consistent styling, responsive design, and better maintainability across the codebase.
务必使用中的核心组件,而非通过Emotion创建自定义styled组件。
@sentry/scraps核心组件可在整个代码库中提供一致的样式、响应式设计以及更好的可维护性。
Component Implementation Reference
组件实现参考
For the complete list of supported props and their types, refer to the implementation files:
- Layout Components:
/static/app/components/core/layout/- - Base container with all layout props
container.tsx - - Flex layout primitive
flex.tsx - - Grid layout primitive
grid.tsx - - Stack layout primitive (Flex with column direction by default)
stack.tsx
- Typography Components:
/static/app/components/core/text/- - Text primitive
text.tsx - - Heading primitive
heading.tsx
如需查看支持的完整属性列表及其类型,请参考实现文件:
- 布局组件:
/static/app/components/core/layout/- - 包含所有布局属性的基础容器
container.tsx - - Flex布局原语
flex.tsx - - Grid布局原语
grid.tsx - - Stack布局原语(默认纵向排列的Flex)
stack.tsx
- 排版组件:
/static/app/components/core/text/- - 文本原语
text.tsx - - 标题原语
heading.tsx
Layout Primitives
布局原语
Important:,Flex, andGridall extendStack. This means every prop available on Container is also available on Flex, Grid, and Stack. When you useContainer, you get all Container props (position, padding, border, overflow, etc.) PLUS the flex-specific props. The same applies to Grid and Stack.<Flex>
重要提示:、Flex和Grid均继承自Stack。这意味着Container支持的所有属性,Flex、Grid和Stack也同样支持。使用Container时,你将获得Container的所有属性(位置、内边距、边框、溢出等),再加上Flex专属属性。Grid和Stack同理。<Flex>
Container
Container
Base layout component that supports all common layout properties. Flex, Grid, and Stack extend Container, inheriting all of its props.
Key Props (see for complete list):
container.tsx- : "static" | "relative" | "absolute" | "fixed" | "sticky"
position - ,
padding,paddingTop,paddingBottom,paddingLeft: SpaceSize tokenspaddingRight - ,
margin, etc.: SpaceSize tokens (deprecated, prefer gap)marginTop - ,
width,height,minWidth,maxWidth,minHeightmaxHeight - ,
border,borderTop,borderBottom,borderLeft: BorderVariant tokensborderRight - : RadiusSize tokens
radius - ,
overflow,overflowX: "visible" | "hidden" | "scroll" | "auto"overflowY - : SurfaceVariant ("primary" | "secondary" | "tertiary")
background - : Various display types
display - Flex item props: ,
flex,flexGrow,flexShrink,flexBasis,alignSelforder - Grid item props: ,
area,rowcolumn
tsx
import {Container} from '@sentry/scraps/layout';
// ❌ Don't create styled components
const Component = styled('div')`
padding: ${space(2)};
border: 1px solid ${p => p.theme.tokens.border.primary};
`;
// ✅ Use Container primitive
<Container padding="md" border="primary">
Content
</Container>;支持所有通用布局属性的基础布局组件。Flex、Grid和Stack均继承自它,拥有其全部属性。
关键属性(完整列表请查看):
container.tsx- : "static" | "relative" | "absolute" | "fixed" | "sticky"
position - 、
padding、paddingTop、paddingBottom、paddingLeft: SpaceSize令牌paddingRight - 、
margin等: SpaceSize令牌(已废弃,优先使用gap)marginTop - 、
width、height、minWidth、maxWidth、minHeightmaxHeight - 、
border、borderTop、borderBottom、borderLeft: BorderVariant令牌borderRight - : RadiusSize令牌
radius - 、
overflow、overflowX: "visible" | "hidden" | "scroll" | "auto"overflowY - : SurfaceVariant("primary" | "secondary" | "tertiary")
background - : 多种显示类型
display - Flex子项属性: 、
flex、flexGrow、flexShrink、flexBasis、alignSelforder - Grid子项属性: 、
area、rowcolumn
tsx
import {Container} from '@sentry/scraps/layout';
// ❌ 请勿创建styled组件
const Component = styled('div')`
padding: ${space(2)};
border: 1px solid ${p => p.theme.tokens.border.primary};
`;
// ✅ 使用Container原语
<Container padding="md" border="primary">
内容
</Container>;Flex
Flex
Use for flex layouts. Extends , inheriting all Container props plus flex-specific props.
<Flex>ContainerFlex-Specific Props (see for complete list):
flex.tsx- : "row" | "row-reverse" | "column" | "column-reverse"
direction - : "start" | "end" | "center" | "baseline" | "stretch"
align - : "start" | "end" | "center" | "between" | "around" | "evenly" | "left" | "right"
justify - : SpaceSize or
gapfor row/column gap"${SpaceSize} ${SpaceSize}" - : "nowrap" | "wrap" | "wrap-reverse"
wrap - : "flex" | "inline-flex" | "none"
display
Plus ALL Container props: , , , , , , , , , flex/grid item props, and more (see Container section above).
positionpaddingmarginwidthheightborderradiusoverflowbackgroundtsx
import {Flex} from '@sentry/scraps/layout';
// ❌ Don't create styled components
const Component = styled('div')`
display: flex;
flex-direction: column;
position: relative;
`;
// ✅ Use Flex primitive with props
<Flex direction="column" position="relative" gap="md">
<Child1 />
<Child2 />
</Flex>;使用实现弹性布局。继承自Container,拥有Container的所有属性及Flex专属属性。
<Flex>Flex专属属性(完整列表请查看):
flex.tsx- : "row" | "row-reverse" | "column" | "column-reverse"
direction - : "start" | "end" | "center" | "baseline" | "stretch"
align - : "start" | "end" | "center" | "between" | "around" | "evenly" | "left" | "right"
justify - : SpaceSize或
gap(用于设置行列间距)"${SpaceSize} ${SpaceSize}" - : "nowrap" | "wrap" | "wrap-reverse"
wrap - : "flex" | "inline-flex" | "none"
display
加上Container的所有属性:、、、、、、、、、Flex/Grid子项属性等(详见上方Container部分)。
positionpaddingmarginwidthheightborderradiusoverflowbackgroundtsx
import {Flex} from '@sentry/scraps/layout';
// ❌ 请勿创建styled组件
const Component = styled('div')`
display: flex;
flex-direction: column;
position: relative;
`;
// ✅ 使用带属性的Flex原语
<Flex direction="column" position="relative" gap="md">
<Child1 />
<Child2 />
</Flex>;Grid
Grid
Use for grid layouts. Extends , inheriting all Container props plus grid-specific props.
<Grid>ContainerGrid-Specific Props (see for complete list):
grid.tsx- : Grid template columns (number or CSS value)
columns - : Grid template rows
rows - : Named grid areas
areas - : SpaceSize or
gapfor row/column gap"${SpaceSize} ${SpaceSize}" - : "start" | "end" | "center" | "baseline" | "stretch" (align-items)
align - : "start" | "end" | "center" | "between" | "around" | "evenly" | "stretch"
alignContent - : "start" | "end" | "center" | "between" | "around" | "evenly" | "stretch" (justify-content)
justify - : "start" | "end" | "center" | "stretch"
justifyItems - : "row" | "column" | "row dense" | "column dense"
flow - ,
autoColumns: Size of auto-generated tracksautoRows
Plus ALL Container props: , , , , , , , , , flex/grid item props, and more (see Container section above).
positionpaddingmarginwidthheightborderradiusoverflowbackgroundtsx
import {Grid} from '@sentry/scraps/layout';
// ❌ Don't create styled components
const Component = styled('div')`
display: grid;
grid-template-columns: repeat(3, 1fr);
gap: ${space(2)};
`;
// ✅ Use Grid primitive
<Grid columns="repeat(3, 1fr)" gap="md">
<Item1 />
<Item2 />
<Item3 />
</Grid>;使用实现网格布局。继承自Container,拥有Container的所有属性及Grid专属属性。
<Grid>Grid专属属性(完整列表请查看):
grid.tsx- : 网格模板列(数字或CSS值)
columns - : 网格模板行
rows - : 命名网格区域
areas - : SpaceSize或
gap(用于设置行列间距)"${SpaceSize} ${SpaceSize}" - : "start" | "end" | "center" | "baseline" | "stretch"(align-items)
align - : "start" | "end" | "center" | "between" | "around" | "evenly" | "stretch"
alignContent - : "start" | "end" | "center" | "between" | "around" | "evenly" | "stretch"(justify-content)
justify - : "start" | "end" | "center" | "stretch"
justifyItems - : "row" | "column" | "row dense" | "column dense"
flow - 、
autoColumns: 自动生成轨道的尺寸autoRows
加上Container的所有属性:、、、、、、、、、Flex/Grid子项属性等(详见上方Container部分)。
positionpaddingmarginwidthheightborderradiusoverflowbackgroundtsx
import {Grid} from '@sentry/scraps/layout';
// ❌ 请勿创建styled组件
const Component = styled('div')`
display: grid;
grid-template-columns: repeat(3, 1fr);
gap: ${space(2)};
`;
// ✅ 使用Grid原语
<Grid columns="repeat(3, 1fr)" gap="md">
<Item1 />
<Item2 />
<Item3 />
</Grid>;Stack
Stack
Use for vertical layouts. Stack is essentially with by default. It also provides for adding separators between items.
<Stack>Flexdirection="column"Stack.SeparatorProps (see for complete list):
stack.tsx- Same as Flex props (inherits all Flex and Container props)
- defaults to "column" (but can be overridden)
direction - component for adding dividers between stack items
Stack.Separator
tsx
import {Stack} from '@sentry/scraps/layout';
// ❌ Don't create styled components for vertical layouts
const Component = styled('div')`
display: flex;
flex-direction: column;
gap: ${space(2)};
`;
// ✅ Use Stack primitive (automatically column direction)
<Stack gap="md">
<Item1 />
<Item2 />
<Item3 />
</Stack>;
// ✅ With separators between items
<Stack gap="md">
<Item1 />
<Stack.Separator />
<Item2 />
<Stack.Separator />
<Item3 />
</Stack>;
// ✅ Stack supports all Flex and Container props
<Stack gap="md" padding="lg" position="relative" border="primary">
<Item1 />
<Item2 />
</Stack>;使用实现纵向布局。Stack本质上是默认的Flex,还提供用于在项之间添加分隔符。
<Stack>direction="column"Stack.Separator属性(完整列表请查看):
stack.tsx- 与Flex属性相同(继承所有Flex和Container属性)
- 默认值为"column"(可手动覆盖)
direction - 组件用于在Stack项之间添加分隔线
Stack.Separator
tsx
import {Stack} from '@sentry/scraps/layout';
// ❌ 请勿为纵向布局创建styled组件
const Component = styled('div')`
display: flex;
flex-direction: column;
gap: ${space(2)};
`;
// ✅ 使用Stack原语(自动为纵向排列)
<Stack gap="md">
<Item1 />
<Item2 />
<Item3 />
</Stack>;
// ✅ 在项之间添加分隔符
<Stack gap="md">
<Item1 />
<Stack.Separator />
<Item2 />
<Stack.Separator />
<Item3 />
</Stack>;
// ✅ Stack支持所有Flex和Container属性
<Stack gap="md" padding="lg" position="relative" border="primary">
<Item1 />
<Item2 />
</Stack>;Typography Primitives
排版原语
Text
Text
Use for all text content. Never use raw , , or elements with text styling.
<Text><p><span><div>Key Props (see for complete list):
text.tsx- : "span" | "p" | "label" | "div" (semantic HTML element)
as - : TextSize ("xs" | "sm" | "md" | "lg" | "xl" | "2xl")
size - : ContentVariant | "muted" (see Content Variant Tokens below)
variant - : "left" | "center" | "right" | "justify"
align - : boolean
bold - : boolean
italic - : boolean
uppercase - : boolean
monospace - : boolean (fixed-width numbers)
tabular - : boolean (truncate with ellipsis)
ellipsis - : "nowrap" | "normal" | "pre" | "pre-line" | "pre-wrap"
wrap - : "wrap" | "nowrap" | "balance" | "pretty" | "stable"
textWrap - : "normal" | "break-all" | "keep-all" | "break-word"
wordBreak - : "compressed" | "comfortable" (line-height)
density - : boolean | "dotted"
underline - : boolean
strikethrough
tsx
import {Text} from '@sentry/scraps/text';
// ❌ Don't create styled text components
const Label = styled('span')`
color: ${p => p.theme.tokens.content.secondary};
font-size: ${p => p.theme.fontSizes.small};
`;
// ❌ Don't use raw elements
<p>This is a paragraph</p>
<span>Status: Active</span>
// ✅ Use Text primitive with semantic 'as' prop
<Text as="p" variant="muted" density="comfortable">
This is a paragraph
</Text>
<Text as="span" bold uppercase>
Status: Active
</Text>所有文本内容均需使用,切勿使用原生、或元素并自定义文本样式。
<Text><p><span><div>关键属性(完整列表请查看):
text.tsx- : "span" | "p" | "label" | "div"(语义化HTML元素)
as - : TextSize("xs" | "sm" | "md" | "lg" | "xl" | "2xl")
size - : ContentVariant | "muted"(详见下方内容变体令牌)
variant - : "left" | "center" | "right" | "justify"
align - : boolean
bold - : boolean
italic - : boolean
uppercase - : boolean
monospace - : boolean(等宽数字)
tabular - : boolean(省略号截断)
ellipsis - : "nowrap" | "normal" | "pre" | "pre-line" | "pre-wrap"
wrap - : "wrap" | "nowrap" | "balance" | "pretty" | "stable"
textWrap - : "normal" | "break-all" | "keep-all" | "break-word"
wordBreak - : "compressed" | "comfortable"(行高)
density - : boolean | "dotted"
underline - : boolean
strikethrough
tsx
import {Text} from '@sentry/scraps/text';
// ❌ 请勿创建自定义文本styled组件
const Label = styled('span')`
color: ${p => p.theme.tokens.content.secondary};
font-size: ${p => p.theme.fontSizes.small};
`;
// ❌ 请勿使用原生元素
<p>这是一段段落</p>
<span>状态:活跃</span>
// ✅ 使用带语义化'as'属性的Text原语
<Text as="p" variant="muted" density="comfortable">
这是一段段落
</Text>
<Text as="span" bold uppercase>
状态:活跃
</Text>Heading
Heading
Use for all headings. Never use raw , , etc. elements.
<Heading><h1><h2>Key Props (see for complete list):
heading.tsx- : "h1" | "h2" | "h3" | "h4" | "h5" | "h6" (REQUIRED)
as - : HeadingSize ("xs" | "sm" | "md" | "lg" | "xl" | "2xl" | "3xl" | "4xl")
size - : Same as Text
variant - : Same as Text
align - ,
italic,monospace: Same as Texttabular - ,
ellipsis,wrap,textWrap: Same as TextwordBreak - : Same as Text
density - ,
underline: Same as Textstrikethrough
Note: and are NOT available on Heading (headings are always bold).
bolduppercasetsx
import {Heading} from '@sentry/scraps/text';
// ❌ Don't style heading elements
const Title = styled('h2')`
font-size: ${p => p.theme.fontSize.md};
font-weight: bold;
`;
// ❌ Don't use raw heading elements
<h2>My Title</h2>
// ✅ Use Heading primitive with semantic 'as' prop
<Heading as="h2">My Title</Heading>
// ✅ With custom size
<Heading as="h3" size="xl">Large H3</Heading>所有标题均需使用,切勿使用原生、等元素。
<Heading><h1><h2>关键属性(完整列表请查看):
heading.tsx- : "h1" | "h2" | "h3" | "h4" | "h5" | "h6"(必填)
as - : HeadingSize("xs" | "sm" | "md" | "lg" | "xl" | "2xl" | "3xl" | "4xl")
size - : 与Text相同
variant - : 与Text相同
align - 、
italic、monospace: 与Text相同tabular - 、
ellipsis、wrap、textWrap: 与Text相同wordBreak - : 与Text相同
density - 、
underline: 与Text相同strikethrough
注意:Heading不支持和属性(标题默认加粗)。
bolduppercasetsx
import {Heading} from '@sentry/scraps/text';
// ❌ 请勿为标题元素添加样式
const Title = styled('h2')`
font-size: ${p => p.theme.fontSize.md};
font-weight: bold;
`;
// ❌ 请勿使用原生标题元素
<h2>我的标题</h2>
// ✅ 使用带语义化'as'属性的Heading原语
<Heading as="h2">我的标题</Heading>
// ✅ 自定义尺寸
<Heading as="h3" size="xl">大尺寸H3</Heading>Creating Thin Abstractions
创建轻量抽象
⚠️ CRITICAL: ALWAYS prompt the user for confirmation before creating abstractions over layout primitives (,Container,Flex,Grid,Stack,Text) when the intent is to DRY (Don't Repeat Yourself) repeated props.Heading
You can create thin abstractions over primitives with the purpose of improving the semantic structure by using meaningful names (e.g., vs generic ) and with the purpose of providing some default props. It is very important that you do this sparingly, and only when it is a net gain for readability. For example, if there are only two instances of the duplicated props, and they are placed next to each other, the price of the abstraction outweights the terseness.
TableCellFlexBefore creating an abstraction, you MUST:
- Ask the user for confirmation
- Explain what abstraction you plan to create
- Justify why the abstraction is worth the added complexity
- Wait for explicit approval before proceeding
tsx
import {Flex, type FlexProps} from '@sentry/scraps/layout';
// ❌ Don't repeat the same props everywhere
<Flex align="center" gap="xs" flex="1" padding="sm">Content 1</Flex>
<Flex align="center" gap="xs" flex="1" padding="sm">Content 2</Flex>
<Flex align="center" gap="xs" flex="1" padding="sm">Content 3</Flex>
<Flex align="center" gap="xs" flex="1" padding="sm">Content 4</Flex>
// ✅ Create a thin wrapper with default props (AFTER USER CONFIRMATION)
function TableCell(props: FlexProps) {
return <Flex align="center" gap="md" {...props} />;
}
<TableCell>Content 1</TableCell>
<TableCell>Content 2</TableCell>
<TableCell align="start">Content 3</TableCell>{/* Can override defaults */}Key points:
- ALWAYS prompt for user confirmation BEFORE creating the abstraction
- Extend the primitive's props type ()
extends FlexProps - Set defaults on JSX component and spread to allow overrides
{...props} - Don't use styled components - compose primitives instead
⚠️ 重要提示:当你想要通过抽象布局原语(、Container、Flex、Grid、Stack、Text)来实现DRY(避免重复代码)时,务必先征得用户确认。Heading
你可以基于原语创建轻量抽象,目的是通过有意义的名称(例如而非通用的)提升语义化结构,或提供一些默认属性。请注意务必谨慎使用,仅当能切实提升可读性时才这么做。例如,如果重复属性仅出现两次且位置相邻,那么抽象带来的复杂度将超过代码简洁性的收益。
TableCellFlex创建抽象前,你必须:
- 向用户请求确认
- 说明你计划创建的抽象内容
- 证明该抽象的复杂度是值得的
- 获得明确批准后再执行
tsx
import {Flex, type FlexProps} from '@sentry/scraps/layout';
// ❌ 请勿在各处重复相同属性
<Flex align="center" gap="xs" flex="1" padding="sm">内容1</Flex>
<Flex align="center" gap="xs" flex="1" padding="sm">内容2</Flex>
<Flex align="center" gap="xs" flex="1" padding="sm">内容3</Flex>
<Flex align="center" gap="xs" flex="1" padding="sm">内容4</Flex>
// ✅ 创建带默认属性的轻量包装器(需用户确认后)
function TableCell(props: FlexProps) {
return <Flex align="center" gap="md" {...props} />;
}
<TableCell>内容1</TableCell>
<TableCell>内容2</TableCell>
<TableCell align="start">内容3</TableCell>{/* 可覆盖默认值 */}关键点:
- 创建抽象前务必征得用户确认
- 继承原语的属性类型()
extends FlexProps - 在JSX组件上设置默认值并通过允许覆盖
{...props} - 请勿使用styled组件,而是组合原语
General Guidelines
通用指南
1. Use Responsive Props
1. 使用响应式属性
Most props support responsive syntax using breakpoint keys.
tsx
// ❌ Don't use styled media queries
const Component = styled('div')`
display: flex;
flex-direction: column;
@media screen and (min-width: ${p => p.theme.breakpoints.md}) {
flex-direction: row;
}
`;
// ✅ Use responsive prop signature
<Flex direction={{xs: 'column', md: 'row'}}>大多数属性支持使用断点键的响应式语法。
tsx
// ❌ 请勿使用styled媒体查询
const Component = styled('div')`
display: flex;
flex-direction: column;
@media screen and (min-width: ${p => p.theme.breakpoints.md}) {
flex-direction: row;
}
`;
// ✅ 使用响应式属性签名
<Flex direction={{xs: 'column', md: 'row'}}>2. Prefer Gap/Padding Over Margin
2. 优先使用Gap/内边距而非外边距
Container supports props but they are deprecated. Use on parent containers instead.
margingaptsx
// ❌ Don't use margin between children
const Child = styled('div')`
margin-right: ${p => p.theme.spacing.lg};
`;
// ✅ Use gap on parent container
<Flex gap="lg">
<Child1 />
<Child2 />
</Flex>;Container支持属性但已废弃,建议在父容器上使用替代。
margingaptsx
// ❌ 请勿在子元素间使用外边距
const Child = styled('div')`
margin-right: ${p => p.theme.spacing.lg};
`;
// ✅ 在父容器上使用gap
<Flex gap="lg">
<Child1 />
<Child2 />
</Flex>;3. Split Layout from Typography
3. 分离布局与排版
Don't couple layout and typography in a single styled component. Use separate primitives.
tsx
// ❌ Don't couple layout and typography
const Component = styled('div')`
display: flex;
flex-direction: column;
color: ${p => p.theme.tokens.content.secondary};
font-size: ${p => p.theme.fontSize.lg};
`;
// ✅ Split into layout and typography primitives
<Flex direction="column">
<Text variant="muted" size="lg">
Content
</Text>
</Flex>;请勿在单个styled组件中同时耦合布局与排版,应使用独立的原语。
tsx
// ❌ 请勿耦合布局与排版
const Component = styled('div')`
display: flex;
flex-direction: column;
color: ${p => p.theme.tokens.content.secondary};
font-size: ${p => p.theme.fontSize.lg};
`;
// ✅ 拆分为布局与排版原语
<Flex direction="column">
<Text variant="muted" size="lg">
内容
</Text>
</Flex>;4. Check Implementation Files for All Props
4. 查看实现文件获取完整属性列表
The implementation files contain the complete, up-to-date list of supported props with TypeScript types. When in doubt:
- Read for base layout props
/static/app/components/core/layout/container.tsx - Read for Flex-specific props
/static/app/components/core/layout/flex.tsx - Read for Grid-specific props
/static/app/components/core/layout/grid.tsx - Read for Stack-specific props
/static/app/components/core/layout/stack.tsx - Read for Text props
/static/app/components/core/text/text.tsx - Read for Heading props
/static/app/components/core/text/heading.tsx
实现文件包含了支持的完整属性列表及TypeScript类型。如有疑问:
- 查看获取基础布局属性
/static/app/components/core/layout/container.tsx - 查看获取Flex专属属性
/static/app/components/core/layout/flex.tsx - 查看获取Grid专属属性
/static/app/components/core/layout/grid.tsx - 查看获取Stack专属属性
/static/app/components/core/layout/stack.tsx - 查看获取Text属性
/static/app/components/core/text/text.tsx - 查看获取Heading属性
/static/app/components/core/text/heading.tsx
Token Reference
令牌参考
Spacing Tokens (SpaceSize)
间距令牌(SpaceSize)
Use these for , :
gappadding- ,
"0","2xs","xs","sm","md","lg","xl","2xl""3xl" - Multiple values: (vertical horizontal)
"md lg" - Responsive:
{{xs: "sm", md: "lg"}}
用于、:
gappadding- ,
"0","2xs","xs","sm","md","lg","xl","2xl""3xl" - 多值:(纵向 横向)
"md lg" - 响应式:
{{xs: "sm", md: "lg"}}
Border Tokens (BorderVariant)
边框令牌(BorderVariant)
Use these for prop:
border- ,
"primary","muted","accent","danger","promotion","success""warning"
用于属性:
border- ,
"primary","muted","accent","danger","promotion","success""warning"
Radius Tokens (RadiusSize)
圆角令牌(RadiusSize)
Use these for prop:
radius- ,
"0","2xs","xs","sm","md","lg","xl","2xl""full"
用于属性:
radius- ,
"0","2xs","xs","sm","md","lg","xl","2xl""full"
Text Size Tokens
文本尺寸令牌
- TextSize: "xs" | "sm" | "md" | "lg" | "xl" | "2xl"
- HeadingSize: "xs" | "sm" | "md" | "lg" | "xl" | "2xl" | "3xl" | "4xl"
- TextSize: "xs" | "sm" | "md" | "lg" | "xl" | "2xl"
- HeadingSize: "xs" | "sm" | "md" | "lg" | "xl" | "2xl" | "3xl" | "4xl"
Surface Variant Tokens (SurfaceVariant)
表面变体令牌(SurfaceVariant)
Use these for prop on layout components:
background- ,
"primary","secondary""tertiary"
用于布局组件的属性:
background- ,
"primary","secondary""tertiary"
Content Variant Tokens (ContentVariant)
内容变体令牌(ContentVariant)
Use these for prop on Text and Heading:
variant- ContentVariant: "primary" | "secondary" | "accent" | "danger" | "promotion" | "success" | "warning"
- Plus "muted": Text and Heading also accept "muted" in addition to ContentVariant values
用于Text和Heading的属性:
variant- ContentVariant: "primary" | "secondary" | "accent" | "danger" | "promotion" | "success" | "warning"
- 额外支持"muted":Text和Heading除ContentVariant值外,还支持"muted"
Quick Reference Checklist
快速参考检查清单
Before creating a styled component, ask:
- ✅ Can I use ,
<Flex>, or<Grid>for layout?<Stack> - ✅ Can I use for vertical layouts with default column direction?
<Stack> - ✅ Can I use for borders/padding/positioning?
<Container> - ✅ Can I use or
<Text>for typography?<Heading> - ✅ Can I use responsive props instead of media queries?
- ✅ Can I use instead of margins?
gap - ✅ Does the primitive support the prop I need? (Check implementation files)
If you answered yes to any of these, use the primitive instead.
创建styled组件前,请自问:
- ✅ 我是否可以使用、
<Flex>或<Grid>实现布局?<Stack> - ✅ 我是否可以使用实现默认纵向排列的布局?
<Stack> - ✅ 我是否可以使用实现边框/内边距/定位?
<Container> - ✅ 我是否可以使用或
<Text>实现排版?<Heading> - ✅ 我是否可以使用响应式属性而非媒体查询?
- ✅ 我是否可以使用替代外边距?
gap - ✅ 原语是否支持我需要的属性?(请查看实现文件)
如果以上任意问题的答案是肯定的,请使用对应的原语。