mirror of
https://github.com/ant-design/ant-design.git
synced 2024-12-05 09:49:57 +08:00
58df74c38e
* docs(badge): replace class component with hooks * docs(button): replace class component with hooks * docs(calendar): replace class component with hooks * docs(card): replace class component with hooks * docs(button): replace class component with hooks * chore(deps): remove webpack devDependencies * docs(cascader): replace class component with hooks * docs(checkbox): replace class component with hooks * docs(collapse): replace class component with hooks * docs(comment): replace class component with hooks * docs(descriptions): replace class component with hooks * docs(config-provider): replace class component with hooks * docs(date-picker): replace class component with hooks * docs(drawer): replace class component with hooks * docs(dropdown): replace class component with hooks * docs(dropdown): replace class component with hooks * docs(empty): replace class component with hooks * docs(grid): replace class component with hooks * docs(input): replace class component with hooks * docs(input-number): replace class component with hooks * docs(demo): fix lint error
1.3 KiB
1.3 KiB
order | title | ||||
---|---|---|---|---|---|
6 |
|
zh-CN
autoSize
属性适用于 textarea
节点,并且只有高度会自动变化。另外 autoSize
可以设定为一个对象,指定最小行数和最大行数。
en-US
autoSize
prop for a textarea
type of Input
makes the height to automatically adjust based on the content. An option object can be provided to autoSize
to specify the minimum and maximum number of lines the textarea will automatically adjust.
import { Input } from 'antd';
const { TextArea } = Input;
export default () => {
const [value, setValue] = React.useState();
// eslint-disable-next-line @typescript-eslint/no-shadow
const onChange = ({ target: { value } }) => {
setValue(value);
};
return (
<>
<TextArea placeholder="Autosize height based on content lines" autoSize />
<div style={{ margin: '24px 0' }} />
<TextArea
placeholder="Autosize height with minimum and maximum number of lines"
autoSize={{ minRows: 2, maxRows: 6 }}
/>
<div style={{ margin: '24px 0' }} />
<TextArea
value={value}
onChange={onChange}
placeholder="Controlled autosize"
autoSize={{ minRows: 3, maxRows: 5 }}
/>
</>
);
};