Skip to main content

DInput

Standard text input component with icon support, validation states, and floating labels.

Basic Usage

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

function App() {
  const [value, setValue] = useState('');
  
  return (
    <DInput 
      label="Email"
      value={value}
      onChange={setValue}
      placeholder="Enter your email"
    />
  );
}

Props

label
string
Input label text
value
string
Input value
placeholder
string
Placeholder text
onChange
(value: string) => void
Change handler that receives the input value
size
ComponentSize
Input size - ‘sm’ or ‘lg’
disabled
boolean
default:"false"
Disables the input
readonly
boolean
default:"false"
Makes input read-only
loading
boolean
default:"false"
Shows loading spinner
invalid
boolean
default:"false"
Shows invalid state
valid
boolean
default:"false"
Shows valid state
hint
string
Helper text below input
floatingLabel
boolean
default:"false"
Enables floating label style
iconStart
string
Icon at start of input
iconEnd
string
Icon at end of input
inputStart
ReactNode
Custom content at start of input
inputEnd
ReactNode
Custom content at end of input

Examples

<DInput 
  label="Username"
  value={username}
  onChange={setUsername}
  placeholder="Enter username"
/>

DInputMask

Masked input for formatted data entry (phone numbers, dates, etc.). Built on top of @react-input/mask.

Basic Usage

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

function App() {
  return (
    <DInputMask 
      label="Phone Number"
      mask="(___) ___-____"
      replacement="_"
      placeholder="(555) 123-4567"
    />
  );
}

Props

Inherits all props from DInput plus:
mask
string
required
Mask pattern (use underscore for input positions)
replacement
string
default:"_"
Character used in mask pattern

Examples

// Phone number
<DInputMask 
  label="Phone"
  mask="(___) ___-____"
  replacement="_"
/>

// Date
<DInputMask 
  label="Date"
  mask="__/__/____"
  replacement="_"
  placeholder="MM/DD/YYYY"
/>

// Credit card
<DInputMask 
  label="Card Number"
  mask="____ ____ ____ ____"
  replacement="_"
/>

DInputPassword

Password input with show/hide toggle functionality.

Basic Usage

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

function App() {
  const [password, setPassword] = useState('');
  
  return (
    <DInputPassword 
      label="Password"
      value={password}
      onChange={setPassword}
    />
  );
}

Props

Inherits all props from DInput except type and iconEnd.
iconEndAriaLabel
string
default:"show/hide password"
Aria label for toggle button

Example

<DInputPassword 
  label="Password"
  value={password}
  onChange={setPassword}
  hint="Must be at least 8 characters"
  invalid={password.length > 0 && password.length < 8}
/>

DInputPin

PIN code input with multiple character fields.

Basic Usage

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

function App() {
  const [pin, setPin] = useState('');
  
  return (
    <DInputPin 
      label="Enter PIN"
      characters={4}
      onChange={setPin}
    />
  );
}

Props

label
string
Input label
characters
number
default:"4"
Number of PIN characters
type
PinInputType
default:"text"
Input type - ‘text’, ‘number’, or ‘tel’
innerInputMode
PinInputMode
default:"text"
Input mode - ‘text’, ‘numeric’, or ‘tel’
secret
boolean
default:"false"
Hides input characters (password style)
disabled
boolean
default:"false"
Disables the input
loading
boolean
default:"false"
Shows loading state
invalid
boolean
default:"false"
Shows invalid state
valid
boolean
default:"false"
Shows valid state
hint
string
Helper text
onChange
(value: string) => void
Called when PIN value changes

Examples

<DInputPin 
  label="Security PIN"
  characters={4}
  onChange={setPin}
/>

DInputCheck

Checkbox and radio input component.

Basic Usage

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

function App() {
  const [checked, setChecked] = useState(false);
  
  return (
    <DInputCheck 
      type="checkbox"
      label="Accept terms and conditions"
      checked={checked}
      onChange={(e) => setChecked(e.target.checked)}
    />
  );
}

Props

type
InputCheckType
required
Input type - ‘checkbox’ or ‘radio’
label
string
Label text
checked
boolean
default:"false"
Checked state
disabled
boolean
default:"false"
Disables the input
invalid
boolean
default:"false"
Shows invalid state
valid
boolean
default:"false"
Shows valid state
indeterminate
boolean
Shows indeterminate state (checkbox only)
hint
string
Helper text
onChange
(event: ChangeEvent<HTMLInputElement>) => void
Change handler

Examples

<DInputCheck 
  type="checkbox"
  label="Subscribe to newsletter"
  checked={subscribe}
  onChange={(e) => setSubscribe(e.target.checked)}
/>

DInputSwitch

Toggle switch component for boolean values.

Basic Usage

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

function App() {
  const [enabled, setEnabled] = useState(false);
  
  return (
    <DInputSwitch 
      label="Enable notifications"
      checked={enabled}
      onChange={setEnabled}
    />
  );
}

Props

label
string
Label text
checked
boolean
Switch state
disabled
boolean
default:"false"
Disables the switch
readonly
boolean
default:"false"
Makes switch read-only
invalid
boolean
default:"false"
Shows invalid state
valid
boolean
default:"false"
Shows valid state
onChange
(checked: boolean) => void
Called when switch is toggled

Example

<DInputSwitch 
  label="Dark mode"
  checked={darkMode}
  onChange={setDarkMode}
/>

<DInputSwitch 
  label="Two-factor authentication"
  checked={twoFactor}
  onChange={setTwoFactor}
  disabled={!isVerified}
/>

Build docs developers (and LLMs) love