r/reactjs • • 6d ago

Show /r/reactjs react-brackets: tournament brackets for React

https://react-brackets.oulabi.dev/

Back in 2020 I published react-brackets, a small component for tournament brackets. I shipped a few versions, got busy, and stopped touching it in 2022.

The library didn't stop, though. Four years later it was still pulling ~11,800 downloads a month, sitting at 136 stars and 65 forks, with issues piling up that I never answered. It was built on styled-components and an abandoned swipe library, only did single elimination, and its connector lines were CSS pseudo-element hacks that broke if you changed a card's size.

People were depending on something I'd walked away from. So I rebuilt it from scratch.

What v2 is:

  • Every common format: single and double elimination (with a grand final reset), round robin, Swiss, two-sided brackets, groups to playoffs

  • Headless: semantic markup with data-* attributes, so you style it with Tailwind, CSS modules, or the optional theme

  • Connector lines measured from your real cards: any card size, any custom match component, right-to-left layouts all just work

  • Actually usable on a phone: one round at a time, still drawn as a bracket, with a swipe that follows your finger

  • Zero runtime dependencies besides React, under 14 kB gzipped

  • A framework-free core (@react-brackets/core) for the logic: seeding, byes, results, standings

Getting the swipe to feel native on iOS was the hardest part. Safari animates cards on the GPU on its own clock, while the connector lines are drawn by JavaScript, so the lines kept trailing the cards by a few frames. The fix was to drive both from one clock in the same frame.

It's a ground-up rewrite, so it's a breaking change from 0.x. There's a migration guide, and the old code lives on the legacy branch.

If you were one of the people still using the old version: sorry for the silence, and thank you. I'd love feedback, especially on formats or use cases I haven't covered.

60 Upvotes

8 comments sorted by

5

u/mohammadou1 5d ago

added multiple examples to the docs hoping it would help in complex use cases https://react-brackets.oulabi.dev/examples

3

u/mohammadou1 5d ago

React native support coming today ๐Ÿ˜ฌ

3

u/AshutoshKS 5d ago

Looks actually really good

1

u/mohammadou1 5d ago

Thank you ๐Ÿ™

2

u/Chaoslordi 1d ago edited 1d ago

I just rolled my own tournament feature using brackets, so I can really see the work behind that. Since it looks better than my solution I may look to refactor it using your solution xD

1

u/mohammadou1 1d ago

I really hope it helps, please let me know if you face any issues or blockers

1

u/mohammadou1 5d ago

Happy to share that react native is now supported https://react-brackets.oulabi.dev/docs/native, please let me know if anything goes wrong as it's considered unstable yet

3

u/Important_Pomelo_407 4d ago

Saw there was no demo video yet, so I made you one. Hereโ€™s the PR: https://github.com/MohOulabi/react-brackets/pull/61

and I used my repo to do it :) https://github.com/yasirwhite/OpenDemo