Skip to main content

DInputSelect

Native HTML select element with icon support and validation states.

Basic Usage

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

function App() {
  const [country, setCountry] = useState<Country>();
  
  const countries = [
    { value: 'us', label: 'United States' },
    { value: 'ca', label: 'Canada' },
    { value: 'mx', label: 'Mexico' },
  ];
  
  return (
    <DInputSelect 
      label="Country"
      options={countries}
      value={country?.value}
      onChange={setCountry}
    />
  );
}

Props

label
string
Select label
options
Array<T>
required
Array of options
value
string | number
Selected value
onChange
(selectedOption: T) => void
Called when selection changes with the selected option object
valueExtractor
(item: T) => string | number
Function to extract value from option object
labelExtractor
(item: T) => string
Function to extract label from option object
size
ComponentSize
Select size - ‘sm’ or ‘lg’
disabled
boolean
default:"false"
Disables the select
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
floatingLabel
boolean
default:"false"
Enables floating label style
iconStart
string
Icon at start
iconEnd
string
Icon at end

Examples

const options = [
  { value: 'option1', label: 'Option 1' },
  { value: 'option2', label: 'Option 2' },
];

<DInputSelect 
  label="Select an option"
  options={options}
  onChange={(selected) => console.log(selected)}
/>

TypeScript Interface

type DefaultOption = {
  value: string | number;
  label: string;
};

type Props<T> =
& BaseProps
& FamilyIconProps
& StartIconProps
& EndIconProps
& {
  id?: string;
  name?: string;
  label?: string;
  disabled?: boolean;
  loading?: boolean;
  invalid?: boolean;
  valid?: boolean;
  hint?: string;
  floatingLabel?: boolean;
  onBlur?: (event: FocusEvent) => void;
  onIconStartClick?: (event: MouseEvent) => void;
  onIconEndClick?: (event: MouseEvent) => void;
  options: Array<T>;
  value?: string | number;
  size?: ComponentSize;
  onChange?: (selectedOption: T) => void;
  valueExtractor?: (item: T) => string | number;
  labelExtractor?: (item: T) => string;
};

DInputRange

Range slider with visual value indicator.

Basic Usage

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

function App() {
  const [value, setValue] = useState('50');
  
  return (
    <DInputRange 
      label="Volume"
      value={value}
      min="0"
      max="100"
      onChange={(e) => setValue(e.target.value)}
    />
  );
}

Props

label
string
Range label
value
string
default:"0"
Current value
min
string
default:"0"
Minimum value
max
string
default:"100"
Maximum value
filledValue
boolean
default:"true"
Shows filled track up to current value
onChange
ChangeEventHandler<HTMLInputElement>
Change handler

Example

<DInputRange 
  label="Price Range"
  value={price}
  min="0"
  max="1000"
  onChange={(e) => setPrice(e.target.value)}
/>

<DInputRange 
  label="Opacity"
  value={opacity}
  min="0"
  max="1"
  step="0.1"
  filledValue={true}
  onChange={(e) => setOpacity(e.target.value)}
/>

DSelect

Advanced select component powered by react-select with custom styling and icon support.

Basic Usage

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

function App() {
  const options = [
    { value: 'chocolate', label: 'Chocolate' },
    { value: 'strawberry', label: 'Strawberry' },
    { value: 'vanilla', label: 'Vanilla' },
  ];
  
  return (
    <DSelect 
      label="Flavor"
      options={options}
      onChange={(option) => console.log(option)}
    />
  );
}

Props

Inherits all props from react-select with additional customizations:
label
string
Select label
hint
string
Helper text
invalid
boolean
default:"false"
Shows invalid state
valid
boolean
default:"false"
Shows valid state
disabled
boolean
Disables the select (alias for isDisabled)
clearable
boolean
Shows clear button (alias for isClearable)
loading
boolean
Shows loading state (alias for isLoading)
searchable
boolean
Enables search (alias for isSearchable)
multi
boolean
Enables multi-select (alias for isMulti)
menuWithMaxContent
boolean
default:"false"
Menu width adjusts to content
floatingLabel
boolean
default:"false"
Enables floating label style
iconStart
string
Icon at start
iconEnd
string
Icon at end

Examples

<DSelect 
  label="Select option"
  options={options}
  onChange={handleChange}
/>

Custom Components

DSelect provides pre-built custom components:
  • DSelect.OptionCheck - Checkbox in options
  • DSelect.OptionIcon - Icon in options
  • DSelect.OptionEmoji - Emoji in options
  • DSelect.SingleValueIconText - Icon with text for selected value
  • DSelect.SingleValueEmoji - Emoji for selected value
  • DSelect.SingleValueEmojiText - Emoji with text for selected value
<DSelect 
  options={[
    { value: 'us', label: 'United States', icon: 'Flag' },
    { value: 'ca', label: 'Canada', icon: 'Flag' },
  ]}
  components={{
    Option: DSelect.OptionIcon,
    SingleValue: DSelect.SingleValueIconText,
  }}
/>

Build docs developers (and LLMs) love