DocsComponentsTemplatesThemesGitHub

Modal

Dialog for focused tasks: header, scrollable body, footer. Traps focus; Esc and scrim close it.

Code

import * as React from 'react';
import { Button, Modal, Select, TextField } from '@fruit-labs/design';

export default function Demo() {
  return (
    <div
      style={{
        position: 'relative',
        height: 430,
        borderRadius: 20,
        overflow: 'hidden',
        background: 'var(--bg)',
      }}
    >
      <Modal
        open
        contained
        {...{
          onClose() {},
        }}
        title="Invite people"
        description="They’ll get an email with a link to this project."
        footer={
          <>
            <Button variant="gray">Cancel</Button>
            <Button>Send invite</Button>
          </>
        }
      >
        <TextField label="Email addresses" placeholder="name@company.com" />
        <Select label="Permission" options={['Can view', 'Can edit']} defaultValue="Can edit" />
      </Modal>
    </div>
  );
}

Install

From npm:

npm install @fruit-labs/design

import { Modal } from '@fruit-labs/design';

Or copy the TypeScript source into your project:

npx shadcn@latest add https://design.fruitlabs.online/r/modal.json

Guidelines

  • Sizes sm 400, md 520, lg 720. Title says the task ("Invite people").
  • Footer: secondary left of primary; primary is the only filled button.
  • Pass contained to render inside a positioned parent (docs, previews).

Props

PropTypeRequired
openbooleanYes
onClose() => voidNo
titleReact.ReactNodeYes
descriptionReact.ReactNodeNo
footerReact.ReactNodeNo
size'sm' | 'md' | 'lg'No
dismissiblebooleanNo
containedbooleanNo
classNamestringNo
childrenReact.ReactNodeNo

Edit this example on GitHub