Skip to main content

DButton

Primary button component with support for variants, colors, sizes, icons, and loading states. Can render as a button or anchor element.

Basic Usage

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

function App() {
  return (
    <DButton 
      text="Click me"
      color="primary"
      onClick={() => console.log('Clicked!')}
    />
  );
}

Props

text
string
Button text content
color
ComponentColor
default:"primary"
Button color theme (primary, secondary, success, danger, warning, info, etc.)
size
ComponentSize
Button size - ‘sm’ or ‘lg’
variant
ButtonVariant
Button variant - ‘outline’ or ‘link’
loading
boolean
default:"false"
Shows loading spinner when true
loadingText
string
Text to display during loading state
loadingAriaLabel
string
Aria label for loading state
disabled
boolean
default:"false"
Disables the button
iconStart
string
Icon name to display at start of button
iconEnd
string
Icon name to display at end of button
href
string
If provided, renders as an anchor tag instead of button
target
string
Link target attribute (when used with href)
type
ButtonType
default:"button"
Button type - ‘button’, ‘submit’, or ‘reset’

Variants

<DButton text="Primary" color="primary" />
<DButton text="Secondary" color="secondary" />
<DButton text="Success" color="success" />
<DButton text="Danger" color="danger" />

With Icons

<DButton 
  text="Save" 
  iconStart="Save" 
  color="primary" 
/>

<DButton 
  text="Next" 
  iconEnd="ArrowRight" 
  color="primary" 
/>

<DButton 
  text="Download" 
  iconStart="Download" 
  iconStartMaterialStyle={true}
  color="success" 
/>

Loading State

<DButton 
  text="Submit" 
  loading={isSubmitting}
  loadingText="Submitting..."
  color="primary" 
/>
<DButton 
  text="Visit Page" 
  href="/page" 
  target="_blank"
  rel="noopener noreferrer"
  color="primary" 
/>

TypeScript Interface

interface Props
  extends Omit<ButtonHTMLAttributes<HTMLButtonElement>, 'color'>,
  BaseProps,
  StartIconProps,
  EndIconProps {
  href?: string;
  target?: React.AnchorHTMLAttributes<HTMLAnchorElement>['target'];
  rel?: React.AnchorHTMLAttributes<HTMLAnchorElement>['rel'];
  color?: ComponentColor;
  size?: ComponentSize;
  variant?: ButtonVariant;
  text?: string;
  loading?: boolean;
  loadingText?: string;
  loadingAriaLabel?: string;
}

DButtonIcon

Icon-only button component for compact interfaces. Supports all button states and can render as button or anchor.

Basic Usage

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

function App() {
  return (
    <DButtonIcon 
      icon="Settings"
      ariaLabel="Open settings"
      color="primary"
      onClick={() => console.log('Settings clicked')}
    />
  );
}

Props

icon
string
required
Icon name to display
ariaLabel
string
Accessible label for screen readers (highly recommended)
color
ComponentColor
default:"primary"
Button color theme
size
ComponentSize
Button size - ‘sm’ or ‘lg’
variant
ButtonVariant
Button variant - ‘outline’ or ‘link’
loading
boolean
default:"false"
Shows loading spinner when true
disabled
boolean
default:"false"
Disables the button
state
InputState
Visual state - ‘focus-visible’, ‘hover’, ‘active’, or ‘disabled’
stopPropagationEnabled
boolean
default:"true"
Whether to stop event propagation on click
href
string
If provided, renders as anchor tag

Examples

<DButtonIcon icon="Search" ariaLabel="Search" />
<DButtonIcon icon="Edit" ariaLabel="Edit" color="primary" />
<DButtonIcon icon="Delete" ariaLabel="Delete" color="danger" />

TypeScript Interface

type Props =
& BaseProps
& FamilyIconProps
& {
  id?: string;
  icon: string;
  size?: ComponentSize;
  variant?: ButtonVariant;
  color?: ComponentColor;
  state?: InputState;
  type?: ButtonType;
  loading?: boolean;
  loadingAriaLabel?: string;
  ariaLabel?: string;
  stopPropagationEnabled?: boolean;
  disabled?: boolean;
  href?: string;
  target?: React.AnchorHTMLAttributes<HTMLAnchorElement>['target'];
  rel?: React.AnchorHTMLAttributes<HTMLAnchorElement>['rel'];
  onClick?: (event: MouseEvent<HTMLButtonElement | HTMLAnchorElement>) => void;
};

Build docs developers (and LLMs) love