Modal

A modal dialog with title, description, body and footer.

Modal rendered by Tarve Modal rendered by Tarve
Native render. The live version loads when this comes into view.

Import

import { Modal } from "@tarve/core";

Usage

Modal.tsx
import { Button, Input, Modal, Row } from "@tarve/core";

let open = true;
let name = "notes.md";

<>
  <Button variant="outline" onClick={() => (open = true)}>
    Rename file
  </Button>
  <Modal
    open={open}
    title="Rename file"
    description="Choose a new name for this file."
    onOpenChange={(next) => {
      open = next;
    }}
    footer={
      <Row gap={8} justify="end">
        <Button variant="outline" onClick={() => (open = false)}>Cancel</Button>
        <Button onClick={() => (open = false)}>Save</Button>
      </Row>
    }
  >
    <Input
      value={name}
      onChange={(value) => {
        name = value;
      }}
    />
  </Modal>
</>

Props

PropTypeDefault
open required boolean—
closeOnEscape booleantrue
closeOnOverlay booleantrue
description string—
footer Child—
onOpenChange (open: boolean) => void—
scrollBody

The panel never grows past the window (24 px margins): title and footer stay put and the body scrolls (a `Scroll`). Default `true`; `false` lays the body out unbounded, as before.

booleantrue
showClose booleantrue
title string—
width number480

Common props

Shared by every component. See descriptions →

childrenclassclassNamehighlightidkeymotionFromonHighlightonPasteonPointerLeaveonPointerMoveonSizeonTransitionEndrovingGroupstyle