uikit icon indicating copy to clipboard operation
uikit copied to clipboard

show whitespaces at beginning of lines of text

Open flo-bit opened this issue 1 year ago • 2 comments

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;

flo-bit avatar Jun 25 '24 00:06 flo-bit

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

bbohlender avatar Jun 25 '24 06:06 bbohlender

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

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

flo-bit avatar Jun 25 '24 17:06 flo-bit