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

show whitespaces at beginning of lines of text #92

Open
flo-bit opened this issue Jun 25, 2024 · 2 comments
Open

show whitespaces at beginning of lines of text #92

flo-bit opened this issue Jun 25, 2024 · 2 comments
Labels
bug Something isn't working

Comments

@flo-bit
Copy link

flo-bit commented Jun 25, 2024

I want to show some text containing multiple lines of code, with some lines being indented by whitespace at the beginning, but I can't get this to work, is this supported/a bug?

this is what I tried:

import { Canvas } from '@react-three/fiber'
import { useState } from 'react';
import { Root, Text } from '@react-three/uikit'

function App() {
  const [text, setText] = useState('Hello \n     World!');

  return (
    <div id="canvas-container">
      <pre>{text}</pre>
      <Canvas>
        <Root backgroundColor="#ccc">
          <Text wordBreak="keep-all" fontWeight="bold" multiline>{text}</Text>
        </Root>
      </Canvas>
    </div>
  )
}

export default App;
@bbohlender
Copy link
Contributor

same issue as in #77
The default text layouting behavior ignores starting and trailing whitespace, which should be configurable instead.

@bbohlender bbohlender added the bug Something isn't working label Jun 25, 2024
@flo-bit
Copy link
Author

flo-bit commented Jun 25, 2024

For anyone looking for a quick workaround, this is what I'm using currently:

<Text
	paddingLeft={(text.match(/^\s*/) || [''])[0].length * 10}
>

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants