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

Bug: Text color doesn't work #485

Open
tphamz opened this issue Apr 30, 2024 · 2 comments
Open

Bug: Text color doesn't work #485

tphamz opened this issue Apr 30, 2024 · 2 comments
Labels
v7 Issues related to Pixi React v7

Comments

@tphamz
Copy link

tphamz commented Apr 30, 2024

Current Behavior

Applying color to text doesn't seem to work. In my case, I was trying to set my text color to white using the fill attribute, with the value either "0xfff" or "white".
Another issue is that when fill is an array, it only accepts numbers

Expected Behavior

Text should render color as the setting

Steps to Reproduce

Here is my sample code written in Typescript:

const nodeTextStyle = new TextStyle({
    fontSize: 20,
    fontWeight: '400',
    fill: 'pink'
  });

...
...
...
<Text text= {node.type} x = {0} y={60} anchor={0.5} style={nodeTextStyle}/>
...

Here is the result:

Screenshot 2024-04-30 at 6 59 19 PM

Environment

  • @pixi/react version: ^7.1.2
  • pixi.js version: ^8.1.0
  • React version: 18.0.0
  • ReactDOM version: 18.0.0
  • Browser & Version: Chrome 124.0.6367.118
  • OS & Version: MacOS Sonoma 14.4.1

Possible Solution

No response

Additional Information

No response

@trezy trezy added v7 Issues related to Pixi React v7 bug Something isn't working labels Jun 15, 2024
@kilisniki
Copy link

Work around for me:
<Text text={Some text} x={10} y={10} style={ new PIXI.TextStyle({ fontSize: 24, fill: 'white', // doesnt work // @ts-ignore _fill: ['#ffffff', '#00ff99'], // work pretty well }) } />

@trezy trezy removed the bug Something isn't working label Dec 13, 2024
@a-pedraza
Copy link

The workaround works well for development, but it has issues when compiling, making it unfeasible to use in production.

 Checking validity of types  .Failed to compile.
./src/components/Galeria/BallTree/index.tsx:22:5
Type error: Object literal may only specify known properties, but '_fill' 
does not exist in type 'Partial<TextStyleOptions>'. Did you mean to write 
'fill'?

Stack:
@pixi/react": "^7.1.2",
"next": "14.2.14",
"pixi.js": "^8.6.4",
"react": "^18.2.0",

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

No branches or pull requests

4 participants