React-Native expo에서 FAB 버튼 만들기

2024. 11. 28. 20:05·Stack/React-Native
반응형

FAB 버튼이란?

우측 하단에 있는 조그마한 버튼을 일반적으로 "Floating Action Button" (FAB) 이라고 칭한다.

추가 이동같은 간단한 작업할때 주로 사용.

FAB 버튼 코드

import { Alert, StyleSheet, Text, TouchableOpacity } from 'react-native';

const FAB: React.FC<Props> = () => {
  const AddLocationListAlert = () => {
    Alert.prompt(//제목 , // 내용 , [
      {
        text: 'Cancel',
        onPress: () => {
            // 취소시 작동하는것
        },
        style: 'cancel',
      },
      {
        text: 'OK',
        onPress: (text) => {
          // ok 누를시 작동하는 것!
        },
      },
    ]);
  };

  return (
    <TouchableOpacity style={styles.fab} onPress={AddLocationListAlert}>
      <Text style={styles.fabText}>+</Text>
    </TouchableOpacity>
  );
};

const styles = StyleSheet.create({
  fab: {
    position: 'absolute',
    bottom: 25,
    right: 25,
    backgroundColor: '#6200ee',
    width: 56,
    height: 56,
    borderRadius: 28,
    justifyContent: 'center',
    alignItems: 'center',
    shadowColor: '#000',
    shadowOpacity: 0.2,
    shadowOffset: { width: 0, height: 2 },
    shadowRadius: 2,
    elevation: 5,
  },
  fabText: {
    color: 'white',
    fontSize: 24,
    fontWeight: 'bold',
  },
});

export default FAB;

FAB 버튼에 Prompt를 이용해 구현해봤다.

구현 샘플

반응형

'Stack > React-Native' 카테고리의 다른 글

[React Native CLI] ios API 키 안전하게 숨기기  (0) 2025.01.07
[React-Native CLI] React Native Encrypted Storage 사용하기  (1) 2025.01.03
React-Native 에서 TextInput 사용해보기  (1) 2024.11.17
React-Native expo 시작하기 (새버전)  (2) 2024.11.15
React-Native 커스텀 폰트 설치하기  (1) 2024.11.14
'Stack/React-Native' 카테고리의 다른 글
  • [React Native CLI] ios API 키 안전하게 숨기기
  • [React-Native CLI] React Native Encrypted Storage 사용하기
  • React-Native 에서 TextInput 사용해보기
  • React-Native expo 시작하기 (새버전)
WHITE_FROST
WHITE_FROST
개발공부리뷰블로그
    반응형
  • WHITE_FROST
    하얀하얀IT
    WHITE_FROST
  • 전체
    오늘
    어제
    • 분류 전체보기 (119)
      • Stack (43)
        • Next.js (7)
        • React (12)
        • React-Native (15)
        • TypeScript (0)
        • Python (2)
        • JavaScript (2)
        • Android (1)
        • DB (2)
        • JAVA (1)
      • Obsidian (1)
      • AI (3)
      • AI Tools (0)
      • Tools (0)
      • Mac (0)
      • Error (7)
      • 알고리즘 정리 (6)
      • 알고리즘 문제풀이 (46)
      • 공부일상 (4)
      • 개발 도구 & 라이브러리 (0)
      • 정보처리기사 (0)
      • 기타 (6)
      • Tip (2)
  • 블로그 메뉴

    • 홈
    • 태그
    • 미디어로그
    • 위치로그
    • 방명록
  • 링크

  • 공지사항

  • 인기 글

  • 태그

    react-native
    Python
    오블완
    코테준비
    알고리즘
    boj
    Next.js
    코딩테스트
    mongodb cloud
    Expo
    error
    reactnative
    리액트네이티브
    ios
    코테
    D2
    SWEA
    react
    hooks
    ReactHook
    React-Native cli
    프로그래머스
    java
    mongoDB Atlas
    javascript
    react-native-maps
    d1
    React Hooks
    티스토리챌린지
    백준
  • 최근 댓글

  • 최근 글

  • hELLO· Designed By정상우.v4.10.5
WHITE_FROST
React-Native expo에서 FAB 버튼 만들기
상단으로

티스토리툴바