Modal
Modalは、メインコンテンツの上にオーバーレイ表示されるダイアログコンポーネントです。 通常のModalと、ユーザーの確認が必要なAlertModalの2タイプを提供します。
2
Types
6
Sizes
2
Scroll Mode
Radix
Base
Playground
Preview
SMModal
Modal
Type
Size
Scroll
Content
Options
Button Style
Cancel
Confirm
const [open, setOpen] = useState(false)
<Modal open={open} onOpenChange={setOpen}>
<ModalTrigger asChild>
<Button variant="outline">Open Modal</Button>
</ModalTrigger>
<ModalContent>
<ModalHeader>
<ModalTitle>Modal Title</ModalTitle>
<ModalDescription>This is a description of the modal.</ModalDescription>
</ModalHeader>
<ModalBody>
<p>This is a modal dialog. You can place any content here, including forms, confirmations, or informational messages.</p>
</ModalBody>
<ModalFooter>
<ModalClose asChild>
<Button variant="ghost" size="md" pressEffect={false}>Cancel</Button>
</ModalClose>
<Button size="md" pressEffect={false}>Confirm</Button>
</ModalFooter>
</ModalContent>
</Modal>Sizes
xs簡単な確認・アラートmax-width360px
sm (default)標準(デフォルト)max-width480px
md標準フォームmax-width600px
lg複雑なフォームmax-width760px
xlテーブル・ダッシュボードmax-width960px
fullフル幅max-widthFull
パディング(全サイズ共通)
Header24px (下 0)
Body24px
Footer24px (上 0)
Closeright 16px, top 16px
| Size | max-width | タイトル | 説明文 | 用途 |
|---|---|---|---|---|
xs | 360px | 18px semibold | 14px normal | 簡単な確認 |
sm | 480px | 18px semibold | 14px normal | 確認・アラート(デフォルト) |
md | 600px | 18px semibold | 14px normal | 標準フォーム |
lg | 760px | 18px semibold | 14px normal | 複雑なフォーム |
xl | 960px | 18px semibold | 14px normal | テーブル・ダッシュボード |
full | Full | 18px semibold | 14px normal | フル幅 |
パディング — 全サイズ共通
Header
p-6 pb-0
24px · 下 0
Body
p-6
24px
Footer
p-6 pt-0
24px · 上 0
Close
right-4 top-4
16px
Features
Scroll Behavior
"outside": モーダル全体スクロール。"inside": Bodyのみスクロール、Header/Footer固定。
Sidebar Layout
lg / xl / full サイズ限定。ModalBody を p-0 flex で分割し、左ナビ+右コンテンツのレイアウトを構成できます。
Close Button
falseで閉じるボタン非表示。closeIcon propでアイコン差し替え可能。
API
Component Structure
ModalRadix Dialog.Trigger.ContentProps.Header.Title.Description.Body.Footer.CloseProps.Overlay.Portal
.Triggerトリガー要素.ContentPropsパネル(size・scroll・close).Headerヘッダー領域.Titleタイトル(aria-labelledby).Description補足テキスト(aria-describedby).Bodyコンテンツ領域.Footerアクション領域.CloseProps閉じるボタン.Overlay背景オーバーレイ.PortalポータルAlertModalRadix AlertDialog.Trigger.ContentProps.Header.Title.Description.Body.Footer.Action.Cancel.Overlay.Portal
.Triggerトリガー要素.ContentPropsパネル(size: xs / sm).Headerヘッダー領域.Titleタイトル(aria-labelledby).Description補足テキスト(aria-describedby).Bodyコンテンツ領域.Footerアクション領域.Action確認アクション.Cancelキャンセル.Overlay背景オーバーレイ.PortalポータルProps
ModalContent
size"sm""xs" | "sm" | "md" | "lg" | "xl" | "full"コンテンツの最大幅 (360/480/600/760/960/full)
scrollBehavior"outside""inside" | "outside"オーバーフロー時のスクロール位置
showCloseButtontrueboolean内蔵の閉じるボタンを表示
closeIconBuilt-in SVG iconReactNodeカスタム閉じるアイコン
| Name | Type | Default | Description |
|---|---|---|---|
size | "xs" | "sm" | "md" | "lg" | "xl" | "full" | "sm" | コンテンツの最大幅 (360/480/600/760/960/full) |
scrollBehavior | "inside" | "outside" | "outside" | オーバーフロー時のスクロール位置 |
showCloseButton | boolean | true | 内蔵の閉じるボタンを表示 |
closeIcon | ReactNode | Built-in SVG icon | カスタム閉じるアイコン |
AlertModalContent
size"sm""xs" | "sm"コンテンツの最大幅 (360/480)
| Name | Type | Default | Description |
|---|---|---|---|
size | "xs" | "sm" | "sm" | コンテンツの最大幅 (360/480) |
ModalClose
asChildfalseboolean子要素をトリガーとして使用
| Name | Type | Default | Description |
|---|---|---|---|
asChild | boolean | false | 子要素をトリガーとして使用 |