Skip to content

TkxModal

Basic — click to open
import { TkxModal, TkxButton } from 'tekivex-ui';
import { useState } from 'react';
function Example() {
const [open, setOpen] = useState(false);
return (
<>
<TkxButton onClick={() => setOpen(true)}>Open modal</TkxButton>
<TkxModal
isOpen={open}
onClose={() => setOpen(false)}
title="Confirm action"
>
Are you sure you want to delete this item?
</TkxModal>
</>
);
}
Sizes
<TkxModal size="sm" {...props}>Small — for confirmations</TkxModal>
<TkxModal size="md" {...props}>Default</TkxModal>
<TkxModal size="lg" {...props}>For longer forms</TkxModal>
<TkxModal size="full" {...props}>Full-screen — mobile sheets</TkxModal>
<TkxModal
isOpen={open}
onClose={() => setOpen(false)}
title="Delete account"
footer={
<>
<TkxButton variant="ghost" onClick={() => setOpen(false)}>Cancel</TkxButton>
<TkxButton colorScheme="danger" onClick={handleDelete}>Delete</TkxButton>
</>
}
>
This action cannot be undone.
</TkxModal>
  • role="dialog" and aria-modal="true" on the surface
  • aria-labelledby automatically points at the title
  • Focus trap — Tab cycles only within the modal until closed
  • Initial focus — first focusable element receives focus on open
  • Restored focus — closes return focus to the trigger element
  • Escape closes — unless closeOnEsc={false}
  • Scroll lock — the page beneath cannot scroll
  • Backdrop click closes — unless closeOnBackdropClick={false}
PropTypeRequiredDescription
isOpenbooleanyesControlled open state.
onClose() => voidyesCalled on Escape, backdrop click, or close button.
titleReactNodeHeading shown in the header. Linked via aria-labelledby.
size'sm' | 'md' | 'lg' | 'full'Defaults to md.
closeOnEscbooleanDefaults to true.
closeOnBackdropClickbooleanDefaults to true.
footerReactNodeFooter content (typically action buttons).
initialFocusRefReact.RefObjectOverride the auto-focused element on open.

src/components/TkxModal.tsx