我在带有材质 UI 的输入中使用 Chips,当 chips 占据大部分空间(例如 80%)时,我需要将输入包裹起来,并且 chips 位于顶部并包裹!
<MDInput
value={inputValue}
error={!!errors.tags}
onChange={(event) => setInputValue(event.target.value)}
onKeyDown={handleKeyDown}
onBlur={handleBlurChanges}
label="Press enter to add tag"
name="tags"
helperText={errors?.tags}
InputProps={{
startAdornment: (
<InputAdornment
sx={{
minHeight: "40px",
}}
spacing={1}
position="start"
>
{chips.map((chip, index) => (
<Chip
sx={{
marginRight: "5px",
}}
key={index}
label={chip}
onDelete={handleDelete(chip)}
variant="outlined"
onBlur={handleBlurChanges}
/>
))}
</InputAdornment>
),
}}
/>
你可以把
marginRight:5px
换成marginLeft: 10px