Text
Text 컴포넌트는 span처럼 텍스트를 만드는 데 사용할 수 있는 레이아웃 기본 요소입니다.
스타일이 적용된 span일 뿐입니다.
사용 방법
1import { Text } from '@devup-ui/react' 2 3function App() { 4 return ( 5 <Text color="red" fontSize="24px"> 6 This is Text component. 7 </Text> 8 ) 9}1import { Text } from '@devup-ui/react' 2 3function App() { 4 return ( 5 <Text color="red" fontSize="24px"> 6 This is Text component. 7 </Text> 8 ) 9}
위에서 정의한 Text 컴포넌트는 다음과 같이 렌더링됩니다.
1function App() { 2 return <span className="a b">This is Text component.</span> 3}1function App() { 2 return <span className="a b">This is Text component.</span> 3}
1.a { 2 color: red; 3} 4.b { 5 font-size: 24px; 6}1.a { 2 color: red; 3} 4.b { 5 font-size: 24px; 6}
다른 요소로 렌더링하기
as prop을 사용하면 요소의 타입을 바꿀 수 있습니다.
1import { Text } from '@devup-ui/react' 2 3function App() { 4 return ( 5 <Text as="p" color="red" fontSize="24px"> 6 This is Text component. 7 </Text> 8 ) 9}1import { Text } from '@devup-ui/react' 2 3function App() { 4 return ( 5 <Text as="p" color="red" fontSize="24px"> 6 This is Text component. 7 </Text> 8 ) 9}
위에서 정의한 Text 컴포넌트는 다음과 같이 렌더링됩니다.
1function App() { 2 return <p className="a b">This is Text component.</p> 3}1function App() { 2 return <p className="a b">This is Text component.</p> 3}
1.a { 2 color: red; 3} 4.b { 5 font-size: 24px; 6}1.a { 2 color: red; 3} 4.b { 5 font-size: 24px; 6}
목차
이 페이지 편집