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

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
AlertModalRadix AlertDialog
.Trigger.ContentProps.Header.Title.Description.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"

オーバーフロー時のスクロール位置

showCloseButtontrue
boolean

内蔵の閉じるボタンを表示

closeIconBuilt-in SVG icon
ReactNode

カスタム閉じるアイコン

AlertModalContent

size"sm"
"xs" | "sm"

コンテンツの最大幅 (360/480)

ModalClose

asChildfalse
boolean

子要素をトリガーとして使用