r/reactjs • • 15d 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.

62 Upvotes

11 comments sorted by

View all comments

1

u/SpartanDavie 8d ago

Great idea to make this, I'm sure every dev has made one of these in their time. Much better just to have one good one people can contribute to.

I haven't had a chance to use it yet, so apologies if these are already included:

  1. Most leagues are pretty straight forward but take a look at the Scottish Premiership, can that easily be implemented?
    - Teams play each other twice, then the league splits into top half and bottom half where they play each other once more (not twice).
  2. I just saw https://editorial.uefa.com/resources/02ab-22132d5a5c5c-f3e584d8993b-1000/format/free1/a4_md6_20261115083156.jpeg?imwidth=2048 and I think that would be a neat little feature to add as optional. It uses the remaining number of matches as possible points available to calculate the possible finish for each team.

I'll let you know if anything else comes to mind.

1

u/mohammadou1 5d ago

Thanks for the ideas!

The Scottish split is a good one and I’ll add it in the next release. The library already does leagues and tables, it just needs a few small additions: playing each team three times, splitting the table into a top and bottom half, and keeping the points when the split starts.

The “possible finish” one I’ll leave out. Doing it right is a lot of maths for every league’s rules, and it’s more about stats than brackets. You can still do a simple version yourself: take each team’s points, add the points still left to play, and compare.

Thanks again, and send more if you think of any!