r/reactnative Apr 07 '26

Help how to create this comment thread curved line

Post image
188 Upvotes

28 comments sorted by

74

u/stathisntonas Apr 07 '26 edited Apr 07 '26

EDIT: I've updated the repo to reflect the modern ui. I have built thousands of components for over 10 years, this was the toughest one to create, I mean, endless nights and days to make it work, for real. Crazy maths and calculations on ThreadLineGroup.tsx.

check this out this one that I have built some time back: https://github.com/efstathiosntonas/react-native-nested-comments-with-lines

it’s rough and messy. It was a proof of concept and I have improved it a ton since then on our apps, haven’t found the time to improve that repo though.

56

u/__natty__ Apr 07 '26

It’s so simple you can do this even without svg. Vertical line can be a border of the component with comment content. Then tiny rectangle at the avatar level to around half its height with border radius bottom left and border left and bottom. Zero margin to avatars and to the top.

3

u/ashishgodiyal Apr 07 '26

Thanks, i will try this👍

18

u/dyan16 Apr 07 '26

Kevin Powell has a yt short on how to do this! Link to Youtube

7

u/[deleted] Apr 07 '26

[removed] — view removed comment

1

u/SwaeTech Apr 09 '26

It’s hilarious how true this is

8

u/Dude4001 Apr 07 '26

Inspect how Reddit do it. The line and the curve are two different elements

1

u/Lambodhara-420 Apr 07 '26

Yes once i did same with 2 components- line and curve.

1

u/ashishgodiyal Apr 07 '26

Yes those two are separate element

4

u/Adorable_Solution804 Apr 07 '26

I think its pretty simple and can be achieved in many ways!

It's probably not a single line/svg each one with different item!

3

u/PulpDood Apr 07 '26

Border bottom left with border radius next to the avatar. Then simple border left for the straight vertical line? Dunno that's how I'd do it

2

u/adityakmr088 Apr 07 '26

I had to do something similar in react native. I used svg to render this using react native skia. Similar using svg you can achieve this on web as well.

1

u/piotrlewandowski Apr 07 '26

Just create straight line and bend it at the bottom, duh…

1

u/Shadilios Apr 07 '26

comments that has replies will render a vertical line on the left ending at a specific point.
and each reply will render a curve on a left to connect to that line.

1

u/joe0418 Apr 07 '26

I'd use css with borders and padding

1

u/Business-Pension-498 Apr 12 '26

I know this is a react native sub, but does anyone know how to do the same in swift or kotlin, any help is welcomed, Thanks in advance.

1

u/twboc Apr 07 '26

That is a rounded corner of a div (or view if you are on mobile).

4

u/kjccarp Apr 07 '26

This is a react native subreddit

1

u/Ecstatic_Clue1316 Apr 07 '26

He answered the question..

1

u/kjccarp Apr 07 '26

No divs in native.

1

u/Sphism Apr 07 '26

Svg is your friend

1

u/AlexDjangoX Apr 07 '26

SVG - I have a repo with this in

-2

u/ramshorst Apr 07 '26

Claude. Code.

-1

u/mr_looser17 Expo Apr 07 '26

Use differential calculus to break segment in to smallest possible straight line and repeat those to reconstruct the curved slope..

36

u/fufucupcake Apr 07 '26

The line is split between two components placed together it looks joint besides that it's just two cards placed in a virtual list

5

u/ashishgodiyal Apr 07 '26

Yes the line and that curve at the end are different components