Ignite UI for React 텍스트 영역은 여러 줄로 된 일반 텍스트 편집 컨트롤을 나타내며, 사용자가 상당한 양의 자유형 텍스트(예: 검토 또는 피드백 양식에 대한 주석)를 입력할 수 있도록 허용하려는 경우에 유용합니다.
React 텍스트 영역 예제
EXAMPLE
TSX
CSS
importReactfrom'react';
importReactDOMfrom'react-dom/client';
import'./index.css';
import { IgrTextarea } from"@infragistics/igniteui-react";
import'igniteui-webcomponents/themes/light/bootstrap.css';
exportdefaultfunction TextAreaOverview() {
return (
<divclassName="sample"><IgrTextarearows={3}label="Tell us your story:"><span>It was a dark and stormy night...</span></IgrTextarea></div>
);
}
// rendering above component to the React DOMconstroot = ReactDOM.createRoot(document.getElementById('root'));
root.render(<TextAreaOverview/>);
tsx
/* shared styles are loaded from: *//* https://static.infragistics.com/xplatform/css/samples */css
이 샘플이 마음에 드시나요? Ignite UI for React 전체에 액세스하고 몇 분 만에 나만의 앱을 빌드하기 시작하세요. 무료로 다운로드하세요.
<IgrTextarearows="5"label="Tell us your story:"><span>It was a dark and stormy night...</span></IgrTextarea>tsx
접두사, 접미사 & 도우미 텍스트
및 suffix 슬롯을 사용하면 prefix 텍스트 영역의 기본 콘텐츠 앞뒤에 다른 콘텐츠를 추가할 수 있습니다. 슬롯은 helper-text 텍스트 영역 아래에 배치된 힌트를 제공합니다. 다음 샘플에서는 텍스트 접두사, 아이콘 접미사 및 도우미 텍스트를 힌트로 사용하여 새 텍스트 영역 필드를 만듭니다.
EXAMPLE
TSX
CSS
importReact, { useEffect } from'react';
importReactDOMfrom'react-dom/client';
import'./index.css';
import { IgrTextarea, IgrIcon, registerIconFromText } from"@infragistics/igniteui-react";
import'igniteui-webcomponents/themes/light/bootstrap.css';
exportdefaultfunction TextAreaSlots() {
useEffect(() => {
registerIconFromText( "feedback",
`<svgxmlns="http://www.w3.org/2000/svg"height="24"viewBox="0 -960 960 960"width="24"><pathd="M480-360q17 0 28.5-11.5T520-400q0-17-11.5-28.5T480-440q-17 0-28.5 11.5T440-400q0 17 11.5 28.5T480-360Zm-40-160h80v-240h-80v240ZM80-80v-720q0-33 23.5-56.5T160-880h640q33 0 56.5 23.5T880-800v480q0 33-23.5 56.5T800-240H240L80-80Zm126-240h594v-480H160v525l46-45Zm-46 0v-480 480Z"/></svg>`,
"material");
}, []);
return (
<divclassName="sample"><IgrTextarealabel="Your feedback"><spanslot="prefix"><IgrIconname='feedback'collection="material"></IgrIcon></span><pslot="helper-text">Give us a short description of what you liked/disliked</p></IgrTextarea></div>
);
}
// rendering above component to the React DOMconstroot = ReactDOM.createRoot(document.getElementById('root'));
root.render(<TextAreaSlots/>);
tsx
/* shared styles are loaded from: *//* https://static.infragistics.com/xplatform/css/samples */css
텍스트 영역 크기 조정
세 가지 크기 조정 옵션이 IgrTextarea 있습니다. 로 none 설정하면 텍스트 영역의 크기가 조정되지 않고 스크롤 막대를 사용하여 오버플로 텍스트를 표시합니다. (기본 옵션)으로 vertical 설정하면 텍스트 영역을 통해 사용자가 세로로 크기를 조정할 수 있습니다. 로 auto 설정하면 텍스트 영역에 모든 사용자 입력이 한 번에 표시됩니다. 오버플로 텍스트는 새 줄로 줄 바꿈되고 텍스트 영역이 자동으로 확장됩니다.
EXAMPLE
TSX
CSS
importReactfrom'react';
importReactDOMfrom'react-dom/client';
import'./index.css';
import { IgrTextarea } from"@infragistics/igniteui-react";
import'igniteui-webcomponents/themes/light/bootstrap.css';
exportdefaultfunction TextAreaResize() {
return (
<divclassName="sample"><IgrTextarealabel="Resize: none"resize="none"><pslot="helper-text">This textarea does not resize and uses a scroll bar to show overflow text.</p></IgrTextarea><IgrTextarealabel="Resize: vertical (default)"><pslot="helper-text">This textarea lets the user resize vertically.</p></IgrTextarea><IgrTextarealabel="Resize: auto"resize="auto"><pslot="helper-text">This textarea shows all the user input at once. Overflow text wraps onto a new line and expands the text area.</p></IgrTextarea></div>
);
}
// rendering above component to the React DOMconstroot = ReactDOM.createRoot(document.getElementById('root'));
root.render(<TextAreaResize/>);
tsx
/* shared styles are loaded from: *//* https://static.infragistics.com/xplatform/css/samples */css