import * as combobox from '@remix-run/ui/combobox' import * as dialog from '@remix-run/ui/dialog' import * as menu from '@remix-run/ui/menu' import * as popover from '@remix-run/ui/popover' import * as select from '@remix-run/ui/select' import * as toast from '@remix-run/ui/toast' import { animateEntrance, animateExit, prefersReducedMotion } from '@remix-run/ui/animation' import { Portal, css, on } from 'remix/component' import type { Handle } from 'remix/component' const toastManager = toast.createToastManager() export default function ExampleStackingDialog(handle: Handle) { return () => (

Dialog with other patterns

Open different patterns inside the dialog to try their stacking, focus and dismissal together.

{options.map((option) => (
{option.label}
))}
Action A
Submenu
Action B
Action C

Nested dialog

) } function ExampleSelect(handle: Handle<{ label: string; focusOnShow?: boolean }>) { return () => (
{handle.props.label}
{options.map((option) => (
{option.label}
))}
) } function ExamplePopover(handle: Handle) { let open = false return () => ( ) } const options = [ { label: 'Option A', value: 'a' }, { label: 'Option B', value: 'b' }, { label: 'Option C', value: 'c' }, ] function SelectedLabel(handle: Handle) { let context = handle.context.get(select.Context) return () => {context.displayedLabel} } function ToastRegion() { return () => ( {(toastItems) => { let reducedMotion = prefersReducedMotion() return (
{toastItems.map((toastItem) => (

{toastItem.title}

))}
) }}
) } const styles = { theme: css({ colorScheme: 'light dark', color: 'light-dark(#202027, #eeeef2)', font: '14px/1.6 ui-sans-serif, system-ui, sans-serif', }), button: css({ minHeight: '40px', padding: '8px 14px', border: '1px solid light-dark(#d8d8df, #44444c)', borderRadius: '8px', background: 'light-dark(#fff, #25252b)', color: 'inherit', font: 'inherit', cursor: 'pointer', '&:focus': { outline: '2px solid currentColor', outlineOffset: '3px' }, }), popover: css({ boxSizing: 'border-box', margin: 0, padding: '6px', minWidth: '160px', maxWidth: 'calc(100vw - 32px)', border: '1px solid light-dark(#d8d8df, #44444c)', borderRadius: '8px', background: 'light-dark(#fff, #1b1b20)', boxShadow: '0 8px 24px #0003', opacity: 0, transition: 'opacity 140ms ease', '&[data-state="open"]': { opacity: 1, '@starting-style': { opacity: 0 }, }, '&[data-close-animation="none"], &[data-show-reason="hint"]': { transition: 'none' }, '@media (prefers-reduced-motion: reduce)': { transition: 'none' }, }), list: css({ display: 'grid', gap: '2px', maxHeight: '240px', overflow: 'auto', outline: 0 }), option: css({ padding: '8px 12px', borderRadius: '4px', cursor: 'default', '&[hidden]': { display: 'none' }, '&[data-highlighted="true"]': { background: 'light-dark(#eeeef3, #303038)' }, '&[aria-selected="true"]': { fontWeight: 600 }, '&[data-select-flash], &[data-combobox-flash]': { background: 'light-dark(#d6d6e0, #4b4b56)' }, }), menuItem: css({ display: 'flex', justifyContent: 'space-between', gap: '24px', padding: '8px 12px', borderRadius: '4px', outline: 0, cursor: 'default', '&[data-highlighted]': { background: 'light-dark(#eeeef3, #303038)' }, '&[data-menu-flash]': { background: 'light-dark(#d6d6e0, #4b4b56)' }, }), backdrop: css({ background: '#0006', opacity: 1, '&[data-nested]': { opacity: 0, }, transition: 'opacity 140ms ease', '&[data-state="closed"]': { opacity: 0, }, '@starting-style': { opacity: 0, }, '@media (prefers-reduced-motion: reduce)': { transition: 'none', }, }), surface: css({ colorScheme: 'light dark', boxSizing: 'border-box', inset: 0, margin: 'auto', width: 'min(28rem, calc(100vw - 32px))', height: 'max-content', maxHeight: 'calc(100dvh - 32px)', overflow: 'auto', padding: '24px', border: '1px solid light-dark(#d8d8df, #44444c)', borderRadius: '12px', background: 'light-dark(#fff, #1b1b20)', color: 'light-dark(#202027, #eeeef2)', font: '14px/1.6 ui-sans-serif, system-ui, sans-serif', boxShadow: '0 16px 48px #0004', opacity: 1, scale: 'max(0.8, calc(1 - var(--dialog-open-descendant-depth, 0) * 0.07))', translate: '0 calc(var(--dialog-open-descendant-depth, 0) * 16px)', transition: 'opacity 140ms ease-out, scale 120ms ease-out, translate 120ms ease-out', '&::after': { content: "''", position: 'absolute', inset: 0, borderRadius: 'inherit', background: '#000', opacity: 0, pointerEvents: 'none', transition: 'opacity 120ms ease-out', }, '&[data-child-dialog-open]::after': { opacity: 'min(0.5, calc(var(--dialog-open-descendant-depth, 0) * 0.3))', }, '&[data-state="closed"]': { opacity: 0, scale: 0.97, translate: '0 calc(6px + var(--dialog-open-descendant-depth, 0) * 16px)', }, '@starting-style': { opacity: 0, scale: 0.97, translate: '0 calc(6px + var(--dialog-open-descendant-depth, 0) * 16px)', }, '@media (prefers-reduced-motion: reduce)': { transition: 'none', '&::after': { transition: 'none', }, }, '& h2': { margin: '0 0 20px', fontSize: '20px' }, }), actions: css({ display: 'flex', flexWrap: 'wrap', gap: '12px' }), viewport: css({ position: 'fixed', insetInlineEnd: '16px', bottom: 'max(16px, env(safe-area-inset-bottom))', width: 'min(380px, calc(100vw - 32px))', zIndex: 'calc(var(--rmx-layer-base, 0) + 1000)', colorScheme: 'light dark', color: 'light-dark(#202027, #eeeef2)', font: '14px/1.5 "Inter Variable", Inter, ui-sans-serif, system-ui, sans-serif', '&, & *': { boxSizing: 'border-box' }, '&:focus': { outline: '2px solid currentColor', outlineOffset: '3px' }, }), toast: css({ transformOrigin: 'bottom center', animationDuration: '240ms', animationTimingFunction: 'ease-out', '@keyframes toast-pulse-even': { '0%, 100%': { scale: 1 }, '50%': { scale: 1.03 }, }, '@keyframes toast-pulse-odd': { '0%, 100%': { scale: 1 }, '50%': { scale: 1.03 }, }, '@media (prefers-reduced-motion: reduce)': { animationDuration: '0s' }, display: 'flex', alignItems: 'center', gap: '14px', padding: '17px', border: '1px solid light-dark(#dedee5, #41414a)', borderRadius: '12px', background: 'light-dark(#fff, #222228)', boxShadow: '0 8px 28px #00000012, 0 2px 6px #00000008', '&[data-limited]': { display: 'none' }, '&:focus': { outline: '2px solid currentColor', outlineOffset: '3px' }, }), toastTitle: css({ flex: 1, minWidth: 0, margin: 0, fontSize: '13px' }), dismissButton: css({ appearance: 'none', flexShrink: 0, display: 'grid', placeItems: 'center', width: '28px', height: '28px', margin: '0 -5px 0 0', border: 0, borderRadius: '5px', background: 'none', color: 'light-dark(#777780, #a2a2ad)', font: '20px/1 ui-sans-serif, system-ui, sans-serif', cursor: 'pointer', '&:hover': { background: 'light-dark(#f0f0f5, #34343d)' }, '&:focus': { outline: '2px solid currentColor', outlineOffset: '2px' }, }), description: css({ margin: '0 0 24px' }), patterns: css({ display: 'grid', gap: '24px', marginBottom: '24px' }), field: css({ display: 'grid', gap: '10px' }), input: css({ width: '100%', boxSizing: 'border-box' }), selectTrigger: css({ display: 'flex', alignItems: 'center', justifyContent: 'space-between' }), popoverContent: css({ padding: '16px', width: '240px' }), }