Skip to content
프로젝트

소개

React Native를 위한 설계 철학이 뚜렷한 토스트 컴포넌트입니다. @emilkowalski의 sonner를 포팅했습니다.

웹 및 앱 개발

이 수치를 측정하는 방법

What you can do

  • API fully matches Sonner's
  • Multiple variants, including success, error, warning, custom, promise
  • Promise variant with built-in loading state
  • Custom JSX with the custom variant

측정된 스타 증가

in 24h
0
in 7 days
-1
in 15 days
+1
in 1 month
+6

서로 겹치는 기간의 순증가량이며 일별 합계가 아닙니다. 측정값이 없으면 비워 둡니다. 스타는 관심도를 나타내며 품질을 보장하지 않습니다.

README.md

Original

React Native Toasts

An opinionated toast component for React Native. A port of @emilkowalski's sonner.

sonner-native

Features

  • API fully matches Sonner's
  • Multiple variants, including success, error, warning, custom, promise
  • Promise variant with built-in loading state
  • Custom JSX with the custom variant
  • Top, bottom, or center positions
  • Title and description
  • Action button with a callback
  • Custom icons
  • Optionally dismissable with swipe, configurable left or up
  • Dismissable with toast.dismiss(), one or all toasts
  • Highly performant using Reanimated 3, 60 FPS
  • Dark mode built-in
  • Works with Expo
  • NativeWind supported
  • Customizable via styles props
  • Works outside of React components

Showcase

Screenshot 2024-09-06 at 16 33 10 Screenshot 2024-09-06 at 16 32 27 Screenshot 2024-09-06 at 16 32 33 Screenshot 2024-09-06 at 16 32 39 Screenshot 2024-09-06 at 16 33 04

Expo Snack

https://snack.expo.dev/@gunnartorfis/sonner-native

Installation

npx expo install sonner-native

Requirements

To use this package, you also need to install its peer dependencies. Check out their documentation for more information:

Usage

In your App.tsx/entry point

import { Toaster } from 'sonner-native';

function App() {
  return (
    <View>
      <NavigationContainer>...</NavigationContainer>
      <Toaster />
    </View>
  );
}

With Expo Router

When using Expo Router, place the Toaster component in your root layout file (app/_layout.tsx):

import { Toaster } from 'sonner-native';
import { Stack } from 'expo-router';
import { GestureHandlerRootView } from "react-native-gesture-handler";

export default function RootLayout() {
  return (
    <GestureHandlerRootView>
      <Stack>
        <Stack.Screen name="(tabs)" options={{ headerShown: false }} />
        <Stack.Screen name="+not-found" />
      </Stack>
      <Toaster />
    </GestureHandlerRootView>
  );
}

This ensures the toasts will be displayed across all screens in your app.

Show a toast

import { toast } from 'sonner-native';

function SomeComponent() {
  return (
    <Button
      title="Show Toast"
      onPress={() => toast('Hello, World!')}
    />
  );
}

Web support

Even though Sonner Native works on the web, it is not recommended to use it there. Instead, use the original Sonner.

The following setup is recommended. Add a sonner.ts and sonner.web.ts file to your project and import from there instead of from this library directly. That way, sonner will be used on the web and sonner-native on native.

// sonner.ts
export * from 'sonner-native';
// sonner.web.ts
export * from 'sonner';

Documentation

For more advanced usage, check out the documentation

Recording

https://github.com/user-attachments/assets/ccc428ca-37c3-4589-9e8c-f414c40d764c

Contributing

See the contributing guide to learn how to contribute to the repository and the development workflow.

License

MIT


Made with create-react-native-library

관련 프로젝트 살펴보기

불러오는 중…