组件工坊:Reflex 组件库 100 例
·
课程概览
布局
·
Box
·
Flex
·
Stack
·
Grid
·
Container
·
Section
·
Center
·
Spacer
·
Separator
·
Card
·
Inset
·
Aspect Ratio
·
Fragment
排版
·
Text
·
Heading
·
Link
·
Code
·
Markdown
·
Blockquote
·
Quote
·
Strong
·
Em
·
Kbd
表单
·
Button
·
Input
·
Text Area
·
Checkbox
·
Switch
·
Radio Group
·
Select
·
Slider
·
Form
·
Upload
数据展示
·
Badge
·
Avatar
·
Icon
·
Callout
·
List
·
Data List
·
Code Block
·
Progress
·
Spinner
·
Scroll Area
·
Moment
展开与切换
·
Tabs
·
Accordion
·
Segmented Control
浮层
·
Tooltip
·
Popover
·
Hover Card
·
Dialog
·
Alert Dialog
·
Drawer
·
Dropdown Menu
·
Context Menu
·
Toast
动态渲染
·
Cond
·
Match
·
Foreach
·
Auto Scroll
媒体
·
Image
·
Audio
·
Video
表格与数据网格
·
Table
·
Data Table
·
Data Editor
图表
·
Area Chart
·
Bar Chart
·
Line Chart
·
Composed Chart
·
Pie Chart
·
Radar Chart
·
Radial Bar Chart
·
Scatter Chart
·
Funnel Chart
·
Treemap
·
Sankey Chart
·
Error Bar
图表部件
·
Axis
·
Cartesian Grid
·
Chart Tooltip
·
Legend
·
Label
·
Reference
·
Brush
其他图表库
·
Plotly
·
Pyplot
HTML 元素
·
HTML
·
HTML Text
·
HTML Layout
·
HTML Forms
·
HTML Media
·
HTML Tables
·
SVG
其他工具
·
Theme
·
Skeleton
·
Clipboard
·
Html Embed
·
Script
·
Memo
rx.text.quote官方文档
工坊订单
请在公司介绍段落里,不打断句子地以引用形式放入顾客说过的两句话。
rx.text.quote 是放在句子里的短引用。它渲染为 HTML <q> 标签,用倾斜的衬线字体(Radix 主题的引用字体)加以区分,浏览器和屏幕阅读器也能知道这部分是引用。如果要断开句子、单独拎出来引用,请用 rx.blockquote。
His famous quote, Styles come and go. Good design is a language, not a style
, elegantly sums up Massimo's philosophy of design.
rx.text(
"His famous quote, ",
rx.text.quote("Styles come and go. Good design is a language, not a style"),
", elegantly sums up Massimo's philosophy of design.",
)Quote 没有大小、颜色之类的外观属性。它直接沿用外层 rx.text 的大小和颜色,所以外观要在外层文字上设定。因此本页没有属性实验台,而是放了由 State 驱动的示例。
| 属性 | 取值 | 默认值 | 用途 |
|---|---|---|---|
| 子元素 | 字符串、State 值 | 必填 | 要引用的话 |
cite | 地址字符串 | 无 | 引用来源的地址(不显示在页面上) |
此外还接受 id、title、lang 等 HTML 通用属性和基础事件。
在 cite 里写上出处地址,它会作为 HTML 属性保留下来。页面上看不到,所以要给读者看的出处请直接写进句子里。
The guide says Simple is better than complex
, and we agree.
rx.text(
"The guide says ",
rx.text.quote("Simple is better than complex", cite="https://peps.python.org/pep-0020/"),
", and we agree.",
size="4",
)同样的 Quote,放在小号灰色句子里就显得小而灰,放在大号粗体句子或标题里就显得大而粗。
Small: Less is more
Large: Less is more
Less is more
rx.flex(
rx.text("Small: ", rx.text.quote("Less is more"), size="2", color_scheme="gray"),
rx.text("Large: ", rx.text.quote("Less is more"), size="6", weight="bold"),
rx.heading("In a heading: ", rx.text.quote("Less is more"), as_="h3", size="5"),
direction="column",
spacing="3",
)在子元素里放 State 值,值变化时引用内容也会跟着变。下面的按钮只改变引用列表的序号。
As The Zen of Python puts it, Simple is better than complex
.
class QuoteSayingState(rx.State):
sayings: list[dict[str, str]] = [
{"text": "Simple is better than complex", "who": "The Zen of Python"},
{"text": "Readability counts", "who": "The Zen of Python"},
{"text": "Now is better than never", "who": "The Zen of Python"},
]
pick: int = 0
@rx.event
def next_saying(self):
self.pick = (self.pick + 1) % len(self.sayings)
rx.flex(
rx.text(
"As ",
QuoteSayingState.sayings[QuoteSayingState.pick]["who"],
" puts it, ",
rx.text.quote(QuoteSayingState.sayings[QuoteSayingState.pick]["text"]),
".",
size="4",
),
rx.button("Another one", on_click=QuoteSayingState.next_saying, size="1", variant="soft"),
direction="column",
align="start",
spacing="3",
)介绍段落保持为一个 rx.text,只用 rx.text.quote 包住顾客说的两句话。句子不会被打断,读起来自然连贯。
Our support lead calls this the ten-minute rule
: every message gets a first reply within ten minutes. Customers say it feels like talking to a friend
.
rx.card(
rx.text(
"Our support lead calls this the ",
rx.text.quote("ten-minute rule"),
": every message gets a first reply within ten minutes. Customers say it feels ",
rx.text.quote("like talking to a friend"),
".",
size="3",
),
max_width="440px",
)工坊笔记
rx.text.quote("…") 是句子里的短引用(<q>),作为子元素放进 rx.text。
没有外观属性,沿用外层文字的大小和颜色。
cite 只在 HTML 中保留出处地址。
需要单独展示的长引用用 rx.blockquote。
订阅新课时和新课程通知
本课程新增课时或推出后续课程时,我们会发邮件通知你。
问答
关于本课有任何疑问都可以在这里留言。所有语言版本页面的提问会汇集在一起。