Hone UI
Components

InputAdornment

Put an icon, a unit or a button before or after the text of an input.

InputAdornment holds the small element inside the frame of a TextField or Select. The frame spaces it from the text, and a start adornment shrinks the label. It is a client component and reads theme defaultProps.

import InputAdornment from '@hone-ui/react/InputAdornment';

Examples

$

USD

kg

<Stack spacing={2} sx={{ maxWidth: 260 }}>
  <TextField
    label="Amount"
    slotProps={{
      input: {
        startAdornment: <InputAdornment position="start">$</InputAdornment>,
        endAdornment: <InputAdornment position="end">USD</InputAdornment>,
      },
    }}
  />
  <TextField
    variant="filled"
    label="Weight"
    slotProps={{
      input: { endAdornment: <InputAdornment position="end">kg</InputAdornment> },
    }}
  />
</Stack>

A button inside an end adornment stays clickable. Give it an aria-label.

<TextField
  label="Password"
  type={show ? 'text' : 'password'}
  slotProps={{
    input: {
      endAdornment: (
        <InputAdornment position="end">
          <IconButton aria-label="Show password" onClick={() => setShow(!show)}>
            {show ? 'Hide' : 'Show'}
          </IconButton>
        </InputAdornment>
      ),
    },
  }}
/>

Select takes the same element through startAdornment and endAdornment:

<Select
  aria-label="Weight"
  defaultValue="10"
  endAdornment={<InputAdornment position="end">kg</InputAdornment>}
>
  <MenuItem value="10">Ten</MenuItem>
</Select>

Props

PropTypeDefaultDescription
position'start', 'end'requiredWhich side of the text.
childrenReactNodenoneA string renders in Typography body1 with the secondary text color.
disableTypographybooleanfalseKeeps a string child as plain text.
disablePointerEventsbooleanfalseClicks pass through the adornment to the input.
variant'outlined', 'filled', 'standard'from FormControlThe frame of the surrounding input.
componentElementType'div'The root element.
sx, className, style, refStandard. They go to the root element.

Notes

  • In the Material look, the start adornment of a filled field with a label sits 16px lower, so it meets the text. A hiddenLabel field does not need that offset.
  • A bare string or element passed as startAdornment still works. InputAdornment adds the variant classes and the Typography wrapper.

Accessibility

An adornment is part of the visual frame, not a label. Text such as "kg" is read in order with the input. Name any button inside it with aria-label.

On this page