Skip to main content

DModal

Modal dialog component with animations and composable structure.

Basic Usage

import DModal from '@dynamic-framework/ui-react';
import { AnimatePresence } from 'framer-motion';

function App() {
  const [isOpen, setIsOpen] = useState(false);
  
  return (
    <>
      <DButton text="Open Modal" onClick={() => setIsOpen(true)} />
      
      <AnimatePresence>
        {isOpen && (
          <DModal name="exampleModal" onClose={() => setIsOpen(false)}>
            <DModal.Header>Modal Title</DModal.Header>
            <DModal.Body>
              Modal content goes here
            </DModal.Body>
            <DModal.Footer>
              <DButton text="Close" onClick={() => setIsOpen(false)} />
            </DModal.Footer>
          </DModal>
        )}
      </AnimatePresence>
    </>
  );
}

Props

name
string
required
Unique modal identifier
staticBackdrop
boolean
default:"false"
Prevents closing on backdrop click
scrollable
boolean
default:"false"
Makes modal body scrollable
centered
boolean
default:"false"
Vertically centers modal
fullScreen
boolean
default:"false"
Full screen modal
fullScreenFrom
ModalFullScreenFrom
Breakpoint for full screen - ‘sm’, ‘md’, ‘lg’, ‘xl’, or ‘xxl’
size
ModalSize
Modal size - ‘sm’, ‘lg’, or ‘xl’
transition
Transition
Custom Framer Motion transition

Subcomponents

DModal.Header

Modal header section

DModal.Body

Modal body section (main content) Modal footer section (typically for actions)

Examples

<AnimatePresence>
  {isOpen && (
    <DModal name="confirmModal">
      <DModal.Header>Confirm Action</DModal.Header>
      <DModal.Body>
        Are you sure you want to proceed?
      </DModal.Body>
      <DModal.Footer>
        <DButton 
          text="Cancel" 
          variant="outline"
          onClick={() => setIsOpen(false)} 
        />
        <DButton 
          text="Confirm" 
          color="primary"
          onClick={handleConfirm} 
        />
      </DModal.Footer>
    </DModal>
  )}
</AnimatePresence>

TypeScript Interface

type Props = BaseProps & PropsWithChildren<{
  name: string;
  staticBackdrop?: boolean;
  scrollable?: boolean;
  centered?: boolean;
  fullScreen?: boolean;
  fullScreenFrom?: ModalFullScreenFrom;
  size?: ModalSize;
  transition?: Transition;
}>;

type ModalSize = 'sm' | 'lg' | 'xl';
type ModalFullScreenFrom = 'sm' | 'md' | 'lg' | 'xl' | 'xxl';

DOffcanvas

Offcanvas panel that slides in from any edge of the viewport.

Basic Usage

import DOffcanvas from '@dynamic-framework/ui-react';
import { AnimatePresence } from 'framer-motion';

function App() {
  const [isOpen, setIsOpen] = useState(false);
  
  return (
    <>
      <DButton text="Open Menu" onClick={() => setIsOpen(true)} />
      
      <AnimatePresence>
        {isOpen && (
          <DOffcanvas name="menu" openFrom="end">
            <DOffcanvas.Header>
              <h5>Menu</h5>
              <DButtonIcon 
                icon="X" 
                ariaLabel="Close"
                onClick={() => setIsOpen(false)} 
              />
            </DOffcanvas.Header>
            <DOffcanvas.Body>
              Navigation content
            </DOffcanvas.Body>
          </DOffcanvas>
        )}
      </AnimatePresence>
    </>
  );
}

Props

name
string
required
Unique offcanvas identifier
openFrom
OffcanvasPositionToggleFrom
default:"end"
Edge to open from - ‘top’, ‘bottom’, ‘start’, or ‘end’
staticBackdrop
boolean
default:"false"
Prevents closing on backdrop click
scrollable
boolean
default:"false"
Allows body scroll when offcanvas is open
transition
Transition
Custom Framer Motion transition

Subcomponents

DOffcanvas.Header

Offcanvas header section

DOffcanvas.Body

Offcanvas body section Offcanvas footer section

Examples

<AnimatePresence>
  {isOpen && (
    <DOffcanvas name="sideMenu" openFrom="end">
      <DOffcanvas.Header>Menu</DOffcanvas.Header>
      <DOffcanvas.Body>
        <nav>
          <a href="#">Home</a>
          <a href="#">Profile</a>
          <a href="#">Settings</a>
        </nav>
      </DOffcanvas.Body>
    </DOffcanvas>
  )}
</AnimatePresence>

TypeScript Interface

type Props = BaseProps & PropsWithChildren<{
  name: string;
  staticBackdrop?: boolean;
  scrollable?: boolean;
  openFrom?: OffcanvasPositionToggleFrom;
  transition?: Transition;
}>;

type OffcanvasPositionToggleFrom = 'top' | 'bottom' | 'start' | 'end';

DPopover

Popover component with floating UI positioning.

Basic Usage

import DPopover from '@dynamic-framework/ui-react';

function App() {
  const [open, setOpen] = useState(false);
  
  return (
    <DPopover
      open={open}
      setOpen={setOpen}
      renderComponent={(isOpen) => (
        <DButton text="Toggle Popover" />
      )}
    >
      <div className="p-3">
        <h6>Popover Title</h6>
        <p>Popover content goes here</p>
      </div>
    </DPopover>
  );
}

Props

open
boolean
required
Controls popover visibility
setOpen
(open: boolean) => void
Callback to update open state
renderComponent
(open: boolean) => ReactElement
required
Function that renders the trigger element
adjustContentToRender
boolean
default:"false"
Adjusts popover width to content

Examples

function BasicPopover() {
  const [open, setOpen] = useState(false);
  
  return (
    <DPopover
      open={open}
      setOpen={setOpen}
      renderComponent={(isOpen) => (
        <DButtonIcon 
          icon="Info" 
          ariaLabel="Info"
        />
      )}
    >
      <div className="p-3">
        <p>Additional information here</p>
      </div>
    </DPopover>
  );
}

TypeScript Interface

type Props = BaseProps & PropsWithChildren<{
  renderComponent: (open: boolean) => ReactElement<unknown>;
  open: boolean;
  setOpen?: (open: boolean) => void;
  adjustContentToRender?: boolean;
}>;

DTooltip

Tooltip component with customizable triggers and positioning.

Basic Usage

import DTooltip from '@dynamic-framework/ui-react';

function App() {
  return (
    <DTooltip 
      Component={<DButton text="Hover me" />}
      placement="top"
    >
      This is a tooltip
    </DTooltip>
  );
}

Props

Component
ReactNode
required
Element that triggers the tooltip
placement
Placement
default:"top"
Tooltip position - ‘top’, ‘bottom’, ‘left’, ‘right’, etc.
withHover
boolean
default:"true"
Trigger on hover
withFocus
boolean
default:"false"
Trigger on focus
withClick
boolean
default:"false"
Trigger on click
open
boolean
default:"false"
Controlled open state
size
ComponentSize
Tooltip size - ‘sm’ or ‘lg’
offSet
number
Distance from trigger element
padding
number
Padding for shift middleware

Examples

<DTooltip Component={<DButton text="Hover" />}>
  Helpful tooltip text
</DTooltip>

TypeScript Interface

export type Props = BaseProps & PropsWithChildren<{
  childrenClassName?: string;
  offSet?: number;
  padding?: number;
  withHover?: boolean;
  withFocus?: boolean;
  withClick?: boolean;
  open?: boolean;
  size?: ComponentSize;
  placement?: Placement;
  Component: ReactNode;
}>;

DDropdown

Dropdown menu component with action items.

Basic Usage

import DDropdown from '@dynamic-framework/ui-react';

function App() {
  const actions = [
    {
      label: 'Edit',
      icon: 'Edit',
      onClick: () => console.log('Edit clicked')
    },
    {
      label: 'Delete',
      icon: 'Trash',
      color: 'danger' as const,
      onClick: () => console.log('Delete clicked')
    },
  ];
  
  return <DDropdown actions={actions} />;
}

Props

actions
DropdownAction[]
required
Array of dropdown actions
dropdownToggle
(props: { open: boolean, toggle: () => void }) => ReactNode
Custom toggle element renderer
className
string
Additional CSS classes
label
string
required
Action label
onClick
() => void
Click handler for button actions
href
string
Link URL (renders as anchor)
icon
string
Icon name
color
'default' | 'danger' | 'success' | 'warning' | 'info'
Action color variant
disabled
boolean
Disables the action
isDivider
boolean
Renders as divider instead of action

Examples

const actions = [
  {
    label: 'View',
    icon: 'Eye',
    onClick: () => handleView()
  },
  {
    label: 'Edit',
    icon: 'Edit',
    onClick: () => handleEdit()
  },
  { isDivider: true },
  {
    label: 'Delete',
    icon: 'Trash',
    color: 'danger',
    onClick: () => handleDelete()
  },
];

<DDropdown actions={actions} />

TypeScript Interface

export type DropdownAction = {
  onClick?: () => void;
  href?: string;
  disabled?: boolean;
  icon?: string;
  color?: 'default' | 'danger' | 'success' | 'warning' | 'info';
  isDivider?: boolean;
  label: string;
};

type Props = {
  actions: DropdownAction[];
  dropdownToggle?: ((props: { open: boolean, toggle: () => void }) => React.ReactNode);
  className?: string;
};

Build docs developers (and LLMs) love