Skip to main content

DAlert

Alert component for displaying important messages with color variants and optional close button.

Basic Usage

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

function App() {
  return (
    <DAlert color="success">
      Your changes have been saved successfully!
    </DAlert>
  );
}

Props

color
ComponentStateColor
default:"success"
Alert color - ‘success’, ‘danger’, ‘warning’, or ‘info’
icon
string
Custom icon name (auto-selected based on color if not provided)
showClose
boolean
default:"false"
Shows close button
onClose
() => void
Close button click handler
iconClose
string
Custom close icon
iconFamilyClass
string
Icon family class
iconFamilyPrefix
string
Icon family prefix
iconMaterialStyle
boolean
default:"false"
Use Material icon style

Examples

<DAlert color="success">
  Operation completed successfully!
</DAlert>

<DAlert color="danger">
  An error occurred. Please try again.
</DAlert>

<DAlert color="warning">
  Please review your information before submitting.
</DAlert>

<DAlert color="info">
  New features are now available.
</DAlert>

TypeScript Interface

type Props =
& BaseProps
& PropsWithChildren<{
  id?: string;
  color?: ComponentStateColor;
  icon?: string;
  iconFamilyClass?: string;
  iconFamilyPrefix?: string;
  iconMaterialStyle?: boolean;
  showClose?: boolean;
  iconClose?: string;
  iconCloseFamilyClass?: string;
  iconCloseFamilyPrefix?: string;
  iconCloseMaterialStyle?: boolean;
  onClose?: () => void;
}>;

DToast

Toast notification component with composable structure.

Basic Usage

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

function App() {
  return (
    <DToast>
      <DToast.Header>Notification</DToast.Header>
      <DToast.Body>
        Your action was completed successfully.
      </DToast.Body>
    </DToast>
  );
}

Props

className
string
Additional CSS classes
style
CSSProperties
Inline styles

Subcomponents

DToast.Header

Toast header section

DToast.Body

Toast body section

Example

<DToast>
  <DToast.Header>
    <strong className="me-auto">Success</strong>
    <small>Just now</small>
  </DToast.Header>
  <DToast.Body>
    Your transaction has been processed.
  </DToast.Body>
</DToast>

TypeScript Interface

type Props = PropsWithChildren<BaseProps>;

function DToast(props: Props): JSX.Element;

DToast.Header: (props: PropsWithChildren<BaseProps>) => JSX.Element;
DToast.Body: (props: PropsWithChildren<BaseProps>) => JSX.Element;

DProgress

Progress bar component with percentage display and optional striped animation.

Basic Usage

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

function App() {
  return (
    <DProgress 
      currentValue={75} 
      maxValue={100}
    />
  );
}

Props

currentValue
number
required
Current progress value
minValue
number
default:"0"
Minimum value
maxValue
number
default:"100"
Maximum value
hideCurrentValue
boolean
default:"false"
Hides percentage text inside bar
enableStripedAnimation
boolean
default:"false"
Enables animated striped pattern
height
string | number
Custom height for progress bar

Examples

<DProgress currentValue={25} />
<DProgress currentValue={50} />
<DProgress currentValue={75} />
<DProgress currentValue={100} />

TypeScript Interface

type Props = BaseProps & {
  currentValue: number;
  minValue?: number;
  maxValue?: number;
  hideCurrentValue?: boolean;
  enableStripedAnimation?: boolean;
  height?: string | number;
};

DDataStateWrapper

Wrapper component for handling loading, error, and empty states in data fetching scenarios.

Basic Usage

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

function App() {
  const { data, isLoading, isError } = useQuery('users', fetchUsers);
  
  return (
    <DDataStateWrapper
      isLoading={isLoading}
      isError={isError}
      data={data}
      onRetry={refetch}
    >
      {(users) => (
        <ul>
          {users.map(user => (
            <li key={user.id}>{user.name}</li>
          ))}
        </ul>
      )}
    </DDataStateWrapper>
  );
}

Props

isLoading
boolean
required
Indicates loading state
isError
boolean
required
Indicates error state
data
T[] | undefined
required
Array of data items
onRetry
() => void
Retry function called when error state retry button is clicked
renderLoading
Renderable
Custom loading state renderer
renderEmpty
Renderable
Custom empty state renderer
renderError
Renderable
Custom error state renderer
children
(data: T[]) => ReactNode
required
Render function that receives the data array

State Priority

The component handles states in this order:
  1. Loading state (when isLoading is true)
  2. Error state (when isError is true)
  3. Empty state (when data array is empty)
  4. Success state (renders children with data)

Examples

<DDataStateWrapper
  isLoading={isLoading}
  isError={isError}
  data={transactions}
>
  {(transactions) => (
    <table>
      <tbody>
        {transactions.map(tx => (
          <tr key={tx.id}>
            <td>{tx.date}</td>
            <td>{tx.amount}</td>
          </tr>
        ))}
      </tbody>
    </table>
  )}
</DDataStateWrapper>

TypeScript Interface

type Renderable = ReactNode | (() => ReactNode);

type DDataStateWrapperProps<T> = {
  isLoading: boolean;
  isError: boolean;
  data: T[] | undefined;
  onRetry?: () => void;
  renderLoading?: Renderable;
  renderEmpty?: Renderable;
  renderError?: Renderable;
  children: (data: T[]) => ReactNode;
};

export default function DDataStateWrapper<T>(props: DDataStateWrapperProps<T>): ReactNode;

Build docs developers (and LLMs) love