Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

SafeAreaView TW styles not applied #628

Closed
theblondealex opened this issue Nov 9, 2023 · 14 comments
Closed

SafeAreaView TW styles not applied #628

theblondealex opened this issue Nov 9, 2023 · 14 comments

Comments

@theblondealex
Copy link

Nativewind is setup correctly as is working on all other react components except SafeAreaView, see code below

import { View, Text, SafeAreaView, TouchableOpacity } from "react-native";

const HomeScreen = () => {
  return (
    <SafeAreaView
      // style={{ backgroundColor: "blue", height: "100%" }}
      className=" bg-blue-500 h-screen"
    >
      <View className="">
        {/* title */}
        <View>
          <Text className="text-center mt-12 text-4xl font-bold">Test</Text>
        </View>
      </View>
    </SafeAreaView>
  );
};
export default HomeScreen;

the TW styles are working on the View and Text components, however the SafeAreaView component/wrrapper they are not working, changing it to just a View works and the TW styles applied work however not as SafeAreaView, it is not an issue with safeareaview as you can see the commented out native inline styles, these work on the safeareaview.

Here are some setup information

"tailwindcss": "^3.3.2"
"nativewind": "4.0.11",
"expo": "^49.0.0",

see two images for before and after appying the SafeAreaView the bg is removed back to white
WhatsApp Image 2023-11-09 at 10 44 54_11579294
WhatsApp Image 2023-11-09 at 10 45 18_79e2ab73

@GustavoBonfimS
Copy link

0738629

Apparently SafeAreaView will be supported in a future release.

@theblondealex
Copy link
Author

Fantastic just seen the push after this was posted, Appreiciate the work @marklawlor

@PriyobrotoKar
Copy link

PriyobrotoKar commented Mar 31, 2024

I am still facing this exact same issue. The SafeAreaView can be styled with native styling using the style prop but the nativewind's classes aren't working.
Edit: I am facing this issue when rendering the SafeAreaView in Expo's Tab navigation. It's working as expected in the normal Stack navigation.

I am currently using:

    "nativewind": "^4.0.36",
    "tailwindcss": "^3.4.1" ,
    "expo": "~50.0.13"

@pedrohamarques
Copy link

I am still facing this exact same issue. The SafeAreaView can be styled with native styling using the style prop but the nativewind's classes aren't working. Edit: I am facing this issue when rendering the SafeAreaView in Expo's Tab navigation. It's working as expected in the normal Stack navigation.

I am currently using:

    "nativewind": "^4.0.36",
    "tailwindcss": "^3.4.1" ,
    "expo": "~50.0.13"

I'm facing the same problem with TouchableOpacity.

    "nativewind": "4.0.1",
    "tailwindcss": "^3.4.3" ,
    "expo": "~50.0.14"

@PriyobrotoKar
Copy link

I am still facing this exact same issue. The SafeAreaView can be styled with native styling using the style prop but the nativewind's classes aren't working. Edit: I am facing this issue when rendering the SafeAreaView in Expo's Tab navigation. It's working as expected in the normal Stack navigation.
I am currently using:

    "nativewind": "^4.0.36",
    "tailwindcss": "^3.4.1" ,
    "expo": "~50.0.13"

I'm facing the same problem with TouchableOpacity.

    "nativewind": "4.0.1",
    "tailwindcss": "^3.4.3" ,
    "expo": "~50.0.14"

@pedrohamarques try upgrading nativewind to version 4.0.36

thienguen added a commit to UNLV-CS472-672/2024-S-GROUP3-Barbell that referenced this issue Apr 10, 2024
@thienguen
Copy link

I am still facing this exact same issue. The SafeAreaView can be styled with native styling using the style prop but the nativewind's classes aren't working. Edit: I am facing this issue when rendering the SafeAreaView in Expo's Tab navigation. It's working as expected in the normal Stack navigation.

I am currently using:

    "nativewind": "^4.0.36",
    "tailwindcss": "^3.4.1" ,
    "expo": "~50.0.13"

Did you find a work around or has it been fixed, currently facing the same problem with not-so-different versioning.

thienguen added a commit to UNLV-CS472-672/2024-S-GROUP3-Barbell that referenced this issue Apr 12, 2024
* 🚰ci: collect coverage from api, and rename testing command

* 🗑️chore: shadcn removal, reduce bundle size

* 🗑️chore: where else do we delete useless stuff

* 🗑️chore: nah, fk nextjs

* 🐛fix: resolve conflict of tsconfig

and added fonts, a shit tons of it

* ✨feat: default header with gap, ass

* 🐛fix: expo jest now instead of test

* 🐛fix: fk snapshot got hands

* 🐧chore: try to manage packages, but realized we are too late for that

* 🐧chore: wasting

* ♻️chore: versions control

* ♻️chore: versions control II

* ♻️ feat: TUI turbo ITS FK GREAT

* 🐞bugs: fixed tailwind works on sum,d oesn't on others

https://www.nativewind.dev/quick-starts/react-native-cli

setup tailwind section

* 🐞fixed: single quote fixed, no body against it

* 🐧bug: attempt to use marcos bottom sheet,agasin, FAILED

* ♻️code: trash

* Revert "♻️code: trash"

This reverts commit 80d1940.

* 🐧fk: imma need input

* 🐧 ui: lets help others

* 🗑️chore: fixed pnpm audit and versions control, prisma latest

* 📁chore: sleep first, code after,

* 🐞bugS: fixed all your silly mistakes

* 🐞fixed: ts

* 🐧ui: atta boi, google gap-2

* 🐞fixed: help stef before

* 🐧masdasmdlkasd

* 🐧chore: chore

* ♻️ bugs: deployment realted

* 📁bug: wher am i

* ♻️fixed: testin and trpc typed

* 🐧ui: default header

* 🐞bugs: version version of pnpm up caniuse-lite

* 🐧 fluc: better message

* 🐞fluc: aight, real works this time

* 🐧ui: default header, background new color

* 🐧fluc: why tf I keep doing sidequest

* 🐞fixing: sdk 50 maybe, nativewind is ASS

* 🐧fluc: BEEFIEST update sdk

jesus why you do this to me

* ♻️tldr: nativewind/nativewind#628

* Auto stash before merge of "165-frontend-move-header-to-the-correct-location" and "origin/165-frontend-move-header-to-the-correct-location"

* Auto stash before merge of "165-frontend-move-header-to-the-correct-location" and "origin/165-frontend-move-header-to-the-correct-location"

* ⚙️tldr: java 17 instead of 11 now, FK YOU EXPO

* ⚙️tldr: fixing

https://docs.swmansion.com/react-native-gesture-handler/docs/fundamentals/installation

* 🐞bug: gorhom/react-native-bottom-sheet#1332

another broken lib

* 🐞bug: can't fix the bottom sheet, is beyond us

* 🐧feat: layout, 1

* 🐧fluc: layout 1 done,2 more to go

and get rid of the unsued import

* 🐧ui: picker...watf

* 🐧ui: im so sorry guys, workout screen

* 🐧ui: inbox screen structure

* 🐧ui: inbox structure done, now to friends

* 🐧ui: friends done,ui ready

* 🐧ci/cd: tesgting added

* 🐞fix: will write test in the next issue

* 🐧good to go

* 📁fixed: the damn LOGIN of CLERTK

* ♻️build: prisma schema migration init

* ♻️build: standardize ti

* 🐧build: comment out the eas

* 📁chore: fixed

* 📁chore: fixed

seed prod

* Add warning console log for null user data along with todo comment

---------

Co-authored-by: mva919 <mva919@gmail.com>
mva919 pushed a commit to UNLV-CS472-672/2024-S-GROUP3-Barbell that referenced this issue Apr 15, 2024
… to team (#199)

* 🚰ci: collect coverage from api, and rename testing command

* 🗑️chore: shadcn removal, reduce bundle size

* 🗑️chore: where else do we delete useless stuff

* 🗑️chore: nah, fk nextjs

* 🐛fix: resolve conflict of tsconfig

and added fonts, a shit tons of it

* ✨feat: default header with gap, ass

* 🐛fix: expo jest now instead of test

* 🐛fix: fk snapshot got hands

* 🐧chore: try to manage packages, but realized we are too late for that

* 🐧chore: wasting

* ♻️chore: versions control

* ♻️chore: versions control II

* ♻️ feat: TUI turbo ITS FK GREAT

* 🐞bugs: fixed tailwind works on sum,d oesn't on others

https://www.nativewind.dev/quick-starts/react-native-cli

setup tailwind section

* 🐞fixed: single quote fixed, no body against it

* 🐧bug: attempt to use marcos bottom sheet,agasin, FAILED

* ♻️code: trash

* Revert "♻️code: trash"

This reverts commit 80d1940.

* 🐧fk: imma need input

* 🐧 ui: lets help others

* 🗑️chore: fixed pnpm audit and versions control, prisma latest

* 📁chore: sleep first, code after,

* 🐞bugS: fixed all your silly mistakes

* 🐞fixed: ts

* 🐧ui: atta boi, google gap-2

* 🐞fixed: help stef before

* 🐧masdasmdlkasd

* 🐧chore: chore

* ♻️ bugs: deployment realted

* 📁bug: wher am i

* ♻️fixed: testin and trpc typed

* 🐧ui: default header

* 🐞bugs: version version of pnpm up caniuse-lite

* 🐧 fluc: better message

* 🐞fluc: aight, real works this time

* 🐧ui: default header, background new color

* 🐧fluc: why tf I keep doing sidequest

* 🐞fixing: sdk 50 maybe, nativewind is ASS

* 🐧fluc: BEEFIEST update sdk

jesus why you do this to me

* ♻️tldr: nativewind/nativewind#628

* Auto stash before merge of "165-frontend-move-header-to-the-correct-location" and "origin/165-frontend-move-header-to-the-correct-location"

* Auto stash before merge of "165-frontend-move-header-to-the-correct-location" and "origin/165-frontend-move-header-to-the-correct-location"

* ⚙️tldr: java 17 instead of 11 now, FK YOU EXPO

* ⚙️tldr: fixing

https://docs.swmansion.com/react-native-gesture-handler/docs/fundamentals/installation

* 🐞bug: gorhom/react-native-bottom-sheet#1332

another broken lib

* 🐞bug: can't fix the bottom sheet, is beyond us

* 🐧feat: layout, 1

* 🐧fluc: layout 1 done,2 more to go

and get rid of the unsued import

* 🐧ui: picker...watf

* 🐧ui: im so sorry guys, workout screen

* 🐧ui: inbox screen structure

* 🐧ui: inbox structure done, now to friends

* 🐧ui: friends done,ui ready

* 🐧ci/cd: tesgting added

* 🐞fix: will write test in the next issue

* 🐧good to go

* 📁fixed: the damn LOGIN of CLERTK

* ♻️build: prisma schema migration init

* ♻️build: standardize ti

* 🐧build: comment out the eas

* 📁chore: fixed

* 📁chore: fixed

seed prod

* 🗑️chore: files name and relative path

1. change all routers to..duh routers
2. update all relative path, even if it is test files
3. move all test file to a dedicated folder, avoid clutter
4. about to write picker-modal test

* 🗑️chore: okay, got it, WHO TF WROTE TOGGLE

* 🗑️chore: files name, dadadada

* 🗑️chore:f iles name change again

* 🤦‍♂️ci/cd; divider test pass, failed action-button

rename tests in api to router, specifically

* 🐧ci/cd: passed action-button, now onto picker-modal

* 🐧fluc: testing passed, more snapshot, fk me

* 🤦‍♂️ fluc: revertable, af FK CLERK

* 🤦‍♂️attempt: to fixed the stupid warning

* Revert "🤦‍♂️attempt: to fixed the stupid warning"

This reverts commit 5a6ad2f.

* 🤦‍♂️fixed: signed out fixed, now doing sign in, Jesus

* 🤦‍♂️idk: fk it

* 🐧updateD: snapshot

* ♻️chore: snapshot II

* 🐧fixed: jesus, writeing unit test and fix aaron toggle

* 🐧fluc: extend timeout

* 🤦‍♂️fluc: extend timeout

* 👑fluic: fk

* 🤦‍♂️remove: un need file

* ♻️fixed: ts error from main

* ♻️coverage: brrrr brrrrr
@pitops
Copy link

pitops commented Jun 23, 2024

Why is this closed? Its still not working

@darknight1983
Copy link

I am having this same issue. Whats really weird to me is that it seems to be working fine in some cases. Check out this Youtube video. I know that I configured Nativewind/Tailwindcss correct but Im still having issues.

@OgDev-01
Copy link

This issues should be opened as it has not been fixed for the safeAreaView styling

@Klerith
Copy link

Klerith commented Aug 14, 2024

I know this is not a permanent solution, however, you can use the SafeAreaView from react-native package and works

import { SafeAreaView } from 'react-native';

Instead of

import { SafeAreaView } from 'react-native-safe-area-context';

@pitops
Copy link

pitops commented Aug 15, 2024

@Klerith thats not even a suggestion.

The real suggestion is to just use style={{}}

@OgDev-01
Copy link

Here is what i did as a walk around

import type { SafeAreaViewProps } from "react-native-safe-area-context";
import { SafeAreaView as RNSafeAreaView } from "react-native-safe-area-context";

import { useThemeConfig } from "@/core/hooks/use-theme-config";

import colors from "../colors";

export const SafeAreaView = ({ children, ...props }: SafeAreaViewProps) => {
  const theme = useThemeConfig();
  return (
    <RNSafeAreaView
      // eslint-disable-next-line react-native/no-inline-styles
      style={{
        backgroundColor: theme.dark ? colors.blue.DEFAULT : colors.white,
        flex: 1,
      }}
      {...props}
    >
      {children}
    </RNSafeAreaView>
  );
};

My use case was around adding inline styles for dark and light mode... But the key thing here is to make it reuseable. I don't think you want to add too many styles to a SafeAreaView than flexing it and adding colors.

@luffy-taro
Copy link

luffy-taro commented Oct 4, 2024

    "expo": "~51.0.36",
    "nativewind": "4.1.10",
    "tailwindcss": "^3.4.13"

Similar issue with nativewind 4.1.10, similar issue with pseudo-classes like focus on <View> component. I think both things work in nativewind 2

@ScreamZ
Copy link

ScreamZ commented Oct 7, 2024

Just add

import { cssInterop } from "nativewind";

cssInterop(SafeAreaView, { className: "style" });

In the root layout in the meantime

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests