コンポーネント工房: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.scroll_area公式ドキュメント
工房の注文書
通知ボックスは高さを固定し、通知が増えたらボックスの中だけでスクロールするようにしてください。
rx.scroll_areaは、決まった大きさの中で内容をスクロールする領域です。ブラウザ標準のスクロール機能をそのまま使いながら、スクロールバーだけをどのブラウザでも同じ見た目で描きます。高さ(または幅)を決めておかないと、その中でスクロールは生まれません。
rx.scroll_area(
rx.flex(
rx.text(
"Three fundamental aspects of typography are legibility, readability, and aesthetics. "
"Although in a non-technical sense legible and readable are often used synonymously, "
"typographically they are separate but related concepts."
),
rx.text(
"Legibility describes how easily individual characters can be distinguished from one another. "
"For instance, if a b and an h, or a 3 and an 8, are difficult to distinguish at small sizes, "
"this is a problem of legibility."
),
rx.text(
"Typographers are concerned with legibility insofar as it is their job to select the correct font to use. "
"Using only uppercase letters reduces legibility."
),
direction="column",
spacing="4",
padding_right="16px",
),
type="always",
scrollbars="vertical",
height="180px",
)下の領域は縦にも横にもはみ出しています。scrollbarsでどの方向にスクロールするかを、typeでスクロールバーがいつ表示されるかを決めます。
プロパティを変えてみる
type
scrollbars
rx.scroll_area(
rx.grid(
*[rx.card(rx.text("Card ", i)) for i in range(1, 41)],
columns="8",
spacing="2",
width="900px",
padding="8px",
),
type="hover",
scrollbars="both",
height="180px",
)| プロパティ | 値 | 既定値 | 用途 |
|---|---|---|---|
scrollbars | "vertical" "horizontal" "both" | "both" | スクロールする方向 |
type | "auto" "always" "scroll" "hover" | "hover" | スクロールバーが表示されるタイミング |
scroll_hide_delay | 整数(ミリ秒) | 600 | scroll・hoverのとき、操作をやめてからバーが消えるまでの時間 |
height / width | CSSの長さ | なし | 領域の大きさ。これをはみ出す内容がスクロールされる |
scrollbarsはスクロールする軸を決めます。左から縦だけ、横だけ、両方です。横にスクロールさせるには、内側の内容が領域より広くなければなりません。
rx.grid(
rx.scroll_area(
rx.text("Vertical. " * 40, size="2", padding="8px", padding_right="24px"),
type="always",
scrollbars="vertical",
height="150px",
),
rx.scroll_area(
rx.text("Horizontal. " * 40, size="2", padding="8px", width="700px"),
type="always",
scrollbars="horizontal",
height="150px",
),
rx.scroll_area(
rx.text("Both ways. " * 60, size="2", padding="8px", width="400px"),
type="always",
scrollbars="both",
height="150px",
),
columns="3",
spacing="3",
)typeはスクロールバーをいつ表示するかを決めます。
auto: 内容がはみ出すときだけ表示されます。always: はみ出していてもいなくても常に表示されます。scroll: その方向にスクロールしている間、表示されます。hover: スクロールしている間と、マウスを領域に乗せたときに表示されます。rx.grid(
*[
rx.scroll_area(
rx.flex(
rx.text("type = '" + t + "'", weight="bold"),
rx.text("Legibility describes how easily individual characters can be distinguished. " * 4, size="2"),
direction="column",
spacing="2",
padding="8px",
padding_right="20px",
),
type=t,
scrollbars="vertical",
height="150px",
)
for t in ["auto", "always", "scroll", "hover"]
],
columns="4",
spacing="3",
)typeが"scroll"か"hover"のとき、scroll_hide_delayは操作をやめてからバーが消えるまでの時間(ミリ秒)です。2つの領域をスクロールして手を離してみると、違いがわかります。
rx.grid(
rx.scroll_area(
rx.text("Hides fast. " * 50, size="2", padding="8px", padding_right="20px"),
type="scroll",
scroll_hide_delay=200,
height="120px",
),
rx.scroll_area(
rx.text("Stays for 3 seconds. " * 40, size="2", padding="8px", padding_right="20px"),
type="scroll",
scroll_hide_delay=3000,
height="120px",
),
columns="2",
spacing="3",
)カードの中の通知リストの高さを固定しました。通知が増えてもカードの大きさは変わらず、マウスを乗せるとスクロールバーが現れます。
Notifications
rx.card(
rx.text("Notifications", weight="bold", margin_bottom="2"),
rx.scroll_area(
rx.vstack(
*[
rx.hstack(
rx.avatar(fallback=str(i), size="2", radius="full"),
rx.text("Order #" + str(1000 + i) + " has shipped.", size="2"),
align="center",
padding_right="16px",
)
for i in range(1, 16)
],
spacing="3",
),
type="hover",
scrollbars="vertical",
height="220px",
),
max_width="340px",
)工房ノート
rx.scroll_area(内容, height=…)で、決まった大きさの中だけでスクロールする。
scrollbars: vertical · horizontal · both(既定)。
type: auto · always · scroll · hover(既定)。scroll_hide_delayで消えるまでの時間。
スクロールバーが文字に重ならないよう、内側の内容にpadding_rightを少し付ける。
新しい授業・講座のお知らせを受け取る
この講座に授業が追加されたり、続きの講座が公開されたりしたらメールでお知らせします。
R
ReflexKR
触って学ぶPythonとReflex。すべての例はReflex 0.10.0で実際に動かして確認しています。
ReflexKRはバナー広告なし・無料で運営しています。役に立ったら、コーヒー一杯で応援してください。 ☕ コーヒーで応援する
アフィリエイトと支援について© 2026 ReflexKR · Since 2026 · CC BY-NC 4.0
質問と回答
この回について気になることを書き込んでください。すべての言語のページの質問がここに集まります。