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.jsonGuidelines
- 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
containedto render inside a positioned parent (docs, previews).
Props
| Prop | Type | Required |
|---|---|---|
open | boolean | Yes |
onClose | () => void | No |
title | React.ReactNode | Yes |
description | React.ReactNode | No |
footer | React.ReactNode | No |
size | 'sm' | 'md' | 'lg' | No |
dismissible | boolean | No |
contained | boolean | No |
className | string | No |
children | React.ReactNode | No |