Opening hours
Mon to Fri, 9 am to 6 pm.
コンポーネント工房: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.el.addressrx.el.articlerx.el.asiderx.el.blockquoterx.el.bodyrx.el.ddrx.el.del_rx.el.detailsrx.el.dialogrx.el.dlrx.el.dtrx.el.figcaptionrx.el.footerrx.el.h1 ~ h6rx.el.headrx.el.headerrx.el.hrrx.el.htmlrx.el.lirx.el.linkrx.el.mainrx.el.navrx.el.noscriptrx.el.olrx.el.portalrx.el.prerx.el.scriptrx.el.sectionrx.el.templaterx.el.titlerx.el.ul公式ドキュメント
工房の注文書
お店のお知らせ記事を1本、ヘッダー、本文、補足のヒント、折りたためる質問、連絡先のフッターまで、意味のある HTML 構造で組んでください。
文書の構造と配置を受け持つ HTML 要素です。header・main・footerのように領域に名前を付けるもの、見出しのh1~h6、リストのul・ol・dl、開閉するdetailsまで入っています。
divでも同じ見た目は作れますが、意味のある要素を使えば、スクリーンリーダーや検索エンジンがページの構造を理解できます。
Mon to Fri, 9 am to 6 pm.
rx.el.article(
rx.el.header(rx.el.h2("Opening hours", font_weight="bold")),
rx.el.p("Mon to Fri, 9 am to 6 pm."),
rx.el.footer("Updated today", font_size="12px", color="gray"),
padding="12px",
border="1px solid gray",
border_radius="8px",
)構造の要素はほとんどが共通の属性しか持ちません。固有の属性があるol(reversed)とdetails(open)を動かしてみましょう。
このサイトでは Tailwind の preflight がリストの記号を消すので、記号は CSS のlist_style_typeで復活させます。
プロパティを変えてみる
Shown when the details element is open.
reversed
marker
summary
open
rx.el.div(
rx.el.ol(
rx.el.li("Mix"),
rx.el.li("Bake"),
rx.el.li("Serve"),
reversed=False,
list_style_type="decimal",
padding_left="2em",
),
rx.el.details(
rx.el.summary("More info", cursor="pointer"),
rx.el.p("Shown when the details element is open."),
open=False,
),
)| プロパティ | 値 | 既定値 | 用途 |
|---|---|---|---|
start (ol) | 整数 | 1 | 最初の番号 |
reversed (ol) | True / False | False | 番号を逆順に |
type (ol) | "1" "a" "A" "i" "I" | "1" | 番号の記号。preflight があると CSS のlist_style_typeが代わりを務める |
open (details, dialog) | True / False | False | 開いた状態 |
cite (blockquote, del_) | URL | なし | 引用・修正の出典 |
date_time (del_) | 日付の文字列 | なし | 削除した時刻 |
rel href … (link) | 文字列 | なし | 外部リソースとの接続(文書のヘッド用) |
async_ defer src … (script) | bool・文字列 | なし | script タグ(Script のページを参照) |
headerはヘッダー、navはナビゲーションメニュー、mainは本文、articleは切り離しても意味が通じる記事、asideは補足、sectionはテーマのまとまり、footerはフッター、addressは連絡先です。
どれもスタイルのない箱なので、配置はdisplay="grid"・"flex"のような CSS で決めます。
The main story goes here.
A themed section of the page.
rx.el.div(
rx.el.header(
rx.el.strong("Workshop"),
rx.el.nav(rx.el.span("Home"), rx.el.span("Parts"), rx.el.span("About"), display="flex", gap="12px"),
display="flex",
justify_content="space-between",
padding="8px",
background=rx.color("indigo", 3),
),
rx.el.main(
rx.el.article(rx.el.h3("Post title", font_weight="bold"), rx.el.p("The main story goes here.")),
rx.el.aside("Related links", padding="8px", background=rx.color("gray", 3)),
display="grid",
grid_template_columns="2fr 1fr",
gap="12px",
padding="8px",
),
rx.el.section(rx.el.p("A themed section of the page."), padding="8px", border_top="1px dashed gray"),
rx.el.footer(rx.el.address("hello@example.com"), padding="8px", font_size="13px", color="gray"),
border="1px solid gray",
border_radius="8px",
overflow="hidden",
)preflight のせいで、h1とh3は本文と同じ大きさで表示されます。見出しは意味であって、大きさはfont_sizeで別に決めます。
hrは話題が変わる線、blockquoteは長い引用(citeに出典)、preは空白と改行をそのまま保つテキストです。
del要素は Python の予約語と重なるので、Reflex ではrx.el.del_と書きます(公式ドキュメントの一覧にはrx.el.Delと書かれています)。対になるrx.el.insは新しく挿入したテキストです。
Make it work, make it right, make it fast.
def hello():
print('hi')Price: $20 $15
rx.el.div(
rx.el.h1("h1 with no style"),
rx.el.h3("h3 with no style"),
rx.el.h2("h2 with style", font_size="24px", font_weight="bold"),
rx.el.hr(margin_y="8px"),
rx.el.blockquote(
"Make it work, make it right, make it fast.",
cite="https://wiki.c2.com/?MakeItWorkMakeItRightMakeItFast",
border_left="4px solid gray",
padding_left="12px",
font_style="italic",
),
rx.el.pre("def hello():\n print('hi')", padding="8px", background=rx.color("gray", 3)),
rx.el.p("Price: ", rx.el.del_("$20", date_time="2026-10-01"), " ", rx.el.ins("$15")),
)ulは順序なしリスト、olは番号付きリストで、項目はliです。dlは用語(dt)と説明(dd)の組を並べる説明リストです。
rx.el.div(
rx.el.ul(rx.el.li("Apples"), rx.el.li("Pears"), list_style_type="disc", padding_left="1.5em"),
rx.el.ol(rx.el.li("Third"), rx.el.li("Fourth"), start=3, list_style_type="decimal", padding_left="1.5em"),
rx.el.dl(
rx.el.dt("Box", font_weight="bold"),
rx.el.dd("A container with no meaning.", margin_left="1.5em"),
rx.el.dt("Flex", font_weight="bold"),
rx.el.dd("A row or column of children.", margin_left="1.5em"),
),
display="flex",
gap="24px",
flex_wrap="wrap",
)detailsの中の最初のsummaryがタイトルになり、クリックするとブラウザが自動で開閉します。State は不要です。
dialogはopen属性で開きます。このように開くと背後をふさがない非モーダルのウィンドウになり、画面を覆うモーダルダイアログにはrx.dialogを使うほうが簡単です。
A box the browser opens and closes by itself.
class HtmlLayoutDialogState(rx.State):
is_open: bool = False
@rx.event
def toggle(self):
self.is_open = not self.is_open
rx.el.div(
rx.el.details(
rx.el.summary("What is details?", cursor="pointer"),
rx.el.p("A box the browser opens and closes by itself."),
),
rx.el.button(
"Toggle dialog",
on_click=HtmlLayoutDialogState.toggle,
padding="4px 12px",
border="1px solid gray",
border_radius="6px",
margin_top="12px",
),
rx.el.dialog(
rx.el.p("A non-modal dialog, opened by the open prop."),
open=HtmlLayoutDialogState.is_open,
padding="12px",
border="1px solid gray",
border_radius="8px",
top="40px",
),
position="relative",
min_height="150px",
)figcaptionはfigureの中で、図、表、コードなどの内容に説明を付けます。
rx.el.figure(
rx.el.img(src="https://picsum.photos/id/1080/320/160", alt="Strawberries", border_radius="6px"),
rx.el.figcaption("Fig. 1 - Fresh strawberries", font_size="13px", color="gray", margin_top="4px"),
width="320px",
)templateの中身は画面に描かれず、複製して使うひな形としてだけ残ります。noscriptは JavaScript が無効なブラウザでだけ表示されます。Reflex アプリは JavaScript で動くので、ここでは表示されません。
Only this line is visible.
rx.el.div(
rx.el.p("Only this line is visible."),
# rx.el.template(...) also keeps its content off the page, but React cannot
# hydrate children inside <template>, so it is left out of this live example.
rx.el.noscript("Please turn on JavaScript."),
)html、head、body、title、link、script、portalは、文書全体やヘッド部分の要素です。Reflex がすでにこの枠組みを作ってくれるのでページの中ではほとんど使わず、ここでもコードとしてだけ示します。
React 19 は本文に置いたtitle・linkを文書のヘッドに引き上げるので、ページに描くとこのサイトのタブのタイトルが変わってしまいます。
# Document-level and head elements: Reflex already renders these, so pages rarely use them
rx.el.html(...) # manifest attribute (removed in HTML5)
rx.el.head(...)
rx.el.body(...)
rx.el.title("Page title") # set page titles with @rx.page(title=...)
rx.el.link(rel="stylesheet", href="/styles.css") # add stylesheets with rx.App(stylesheets=[...])
rx.el.script(src="/my-script.js") # use rx.script for scripts (see the Script page)
rx.el.portal(...) # experimental element that never became a standard記事全体はarticle、タイトルと日付はheader、本文はsection、ヒントはaside、質問はdetails、連絡先はfooterの中のaddressです。
Three new dishes join the menu this week.
Yes, the soup and rolls are vegan.
rx.el.article(
rx.el.header(
rx.el.h1("Spring menu is here", font_size="22px", font_weight="bold"),
rx.el.p(rx.el.time("Mar 3, 2026", date_time="2026-03-03"), font_size="13px", color="gray"),
),
rx.el.section(
rx.el.p("Three new dishes join the menu this week."),
rx.el.ul(rx.el.li("Spring rolls"), rx.el.li("Pea soup"), rx.el.li("Lemon tart"), list_style_type="disc", padding_left="1.5em"),
margin_y="8px",
),
rx.el.aside("Tip: book a table early.", padding="8px", background=rx.color("amber", 3), border_radius="6px"),
rx.el.details(
rx.el.summary("Do you have vegan options?", cursor="pointer", font_weight="600"),
rx.el.p("Yes, the soup and rolls are vegan."),
margin_y="8px",
),
rx.el.hr(),
rx.el.footer(rx.el.address("12 Market St · hello@example.com"), font_size="13px", color="gray", margin_top="8px"),
padding="16px",
border="1px solid gray",
border_radius="10px",
max_width="420px",
)工房ノート
header・nav・main・article・section・aside・footer は領域に名前を付ける。配置は CSS で。
h1~h6 は意味にすぎない。preflight の下では大きさを font_size で決める。
ul・ol・li、dl・dt・dd。リストの記号は list_style_type、ol は start・reversed。
details + summary は State なしで開閉。dialog の open は非モーダル、モーダルは rx.dialog。
del は rx.el.del_。html・head・body・title・link は Reflex が受け持つので、ページでは使わない。
新しい授業・講座のお知らせを受け取る
この講座に授業が追加されたり、続きの講座が公開されたりしたらメールでお知らせします。
R
ReflexKR
触って学ぶPythonとReflex。すべての例はReflex 0.10.0で実際に動かして確認しています。
ReflexKRはバナー広告なし・無料で運営しています。役に立ったら、コーヒー一杯で応援してください。 ☕ コーヒーで応援する
アフィリエイトと支援について© 2026 ReflexKR · Since 2026 · CC BY-NC 4.0
質問と回答
この回について気になることを書き込んでください。すべての言語のページの質問がここに集まります。