일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
1 | 2 | 3 | 4 | 5 | ||
6 | 7 | 8 | 9 | 10 | 11 | 12 |
13 | 14 | 15 | 16 | 17 | 18 | 19 |
20 | 21 | 22 | 23 | 24 | 25 | 26 |
27 | 28 | 29 | 30 | 31 |
Tags
- React
- 리액트네이티브
- Android
- react-native-camera-roll
- Typescript
- 타입스크립트
- 자료구조와알고리즘
- react-hook-form
- 제네릭타입
- 코드숨
- 프로그래머스
- reactnative
- js
- javascript
- ios
- 모던자바스크립트
- 배열
- Flipper
- sort( )
- react-native-vision-camera
- react-native
- 유니온타입
- slice
- 크라코
- craco
- 자바스크립트
- 파스에러
- react-native-image-picker
- 리액트쿼리
- 리액트
Archives
- Today
- Total
KassyLog
자주 사용하는 react-native 태그 알아보기 -Button 본문
react-native에는 버튼 태그가 따로 존재한다.
<Button
title="다음"
color="#666666"
onPress={() => {
navigation.navigate("changePw");
}}
/>
예시처럼 버튼 안에 title로 버튼의 이름을 지정할 수 있고 color로 글자 색깔을 지정할 수 있다.
다만 Button 태그 하나로는 color만 변경 가능하고 폰트 변경 및 사이즈 변경 불가하다는 커스텀의 한계가 있다.
Button · React Native
A basic button component that should render nicely on any platform. Supports a minimal level of customization.
reactnative.dev
위 사이트에서 더 자세하게 알 수 있지만 커스터마이징을 하기 위해 내가 사용한 방법은 아래의 예시와 같다.
<View style={styles.nextBtn}>
<Button
title="다음"
color="#666666"
onPress={() => {
navigation.navigate("changePw");
}}
/>
</View>
View를 활용하여 스타일을 변경한 후 감싸주거나
<TouchableWithoutFeedback>
<View style={styles.shortBtn}>
<Text style={styles.nextBtnTxt}>확인</Text>
</View>
</TouchableWithoutFeedback>
<TouchableOpacity>
<View style={styles.shortBtn}>
<Text style={styles.nextBtnTxt}>확인</Text>
</View>
</TouchableOpacity>
TouchableOpacity나 TouchableWithoutFeedback 혹은 Pressable을 활용하여 커스텀 하는 방법을 사용했다.
<Pressable>
<View style={styles.shortBtn}>
<Text style={styles.nextBtnTxt}>확인</Text>
</View>
</Pressable>
여기서 제한 사항이 있는데 View는 onPress를 지원하지 않는다. 따라서 클릭이 필요한 경우는 View를 활용하지 않는 것이 좋다.
'react-native' 카테고리의 다른 글
react-native 로 카메라 기능 (0) | 2023.01.04 |
---|---|
자주 사용하는 react-native 태그 알아보기 -Modal (0) | 2023.01.03 |
React와 React native의 CSS 차이점 (0) | 2022.12.15 |
자주 사용하는 react-native 태그 알아보기 -TextInput(iOS) (0) | 2022.12.10 |
디버깅 메시지 편하게 보기 (0) | 2022.11.08 |