Library / SDK
react/yoga avatar
react/yoga

react/yoga: the flexbox layout engine you embed, not the app you build

Yoga is an embeddable layout engine targeting web standards.

18,924 stars1,562 forksC++MIT

At a glance

What is it?
Yoga is Meta's C++20 flexbox layout engine with bindings for JavaScript, Java, Swift and Python. It is for people who need flexbox semantics inside something that is not a browser, and its real cost is the build and test toolchain around it.
Who is it for?
Adopt Yoga when you are writing a renderer, a terminal UI, a PDF generator or a native view system and you want the browser's flexbox rules rather than a layout algorithm of your own. Do not adopt it if you need a widget toolkit or a styled component layer; Yoga computes positions and sizes and nothing else, and the README documents no rollback path for a layout that comes out wrong.
Can I use it commercially?
Yes. MIT is a permissive licence: you can use, modify and sell software built on it, as long as you keep its copyright and licence notices.
Is it still maintained?
Yes. The repository last received commits 1 day ago.
What is it written in?
Mainly C++, according to GitHub's language statistics.

Answers come from the project's GitHub data, last synced on September 29, 2026, and from our analysis. They are not legal advice.

Editorial analysis

What Yoga actually computes, and who needs that

Yoga is an embeddable layout engine, not an application framework. You build a tree of nodes, give those nodes flexbox properties, and ask Yoga to calculate the position and size of each node. It does not paint, it does not own a window, and it has no component model. Everything above the layout pass is your problem.

That narrow scope is the point. The README describes it as "an embeddable and performant flexbox layout engine with bindings for multiple languages", and the bindings are the reason it exists in its current form. The JavaScript binding is published on npm as yoga-layout, the Java binding on Maven Central as com.facebook.yoga:yoga, and the repository carries a Package.swift for Swift Package Manager. A Python binding is referenced in the related search data rather than in the README excerpt, so treat Python as something to confirm against the published packages before you plan around it.

Who is this for? People writing a renderer. Terminal UI libraries, PDF generators, native view systems and cross-platform toolkits all need to answer the same question: given a tree of boxes with padding, margins, flex direction and wrapping, where does each box go? Yoga answers that question with the same rules a browser uses, which means layout code you already understand transfers without a rewrite.

The mechanism: a C++20 core, generated fixtures, and thin bindings

The main implementation targets C++ 20 with build logic in CMake, and every language binding sits on top of that core. There is no separate JavaScript layout implementation to keep in sync; the bindings are wrappers.

The part of the repository that deserves attention is the test strategy. According to the README, many of Yoga's tests are generated. You write an HTML fixture describing node structure, the generator renders that fixture in Chrome, and the browser's computed layout becomes the expected result for the C++ test. A fixture in the README looks like a div with a fixed width and height, align-items center, containing a smaller fixed-size child.

This is a strong design choice. Flexbox has a long tail of edge cases, and the browser is the reference implementation everyone already agrees on. Deriving expectations from Chrome rather than hand-writing assertions means the test suite tracks real behaviour instead of someone's mental model of it. The cost is that the test suite depends on a headless browser and a yarn workspace to regenerate anything. Adding a fixture is not a one-line diff; it is a generator run.

Installing Yoga and laying out your first tree

There are several install paths depending on your language. The README points at vcpkg for C++ consumers, noting that Yoga is part of the vcpkg collection of ports maintained by Microsoft and community contributors, and that if the version is out of date you should open an issue or pull request on the vcpkg repository rather than here. For JavaScript, the npm package is yoga-layout.

If you are working on Yoga itself rather than consuming it, the repository ships a wrapper script that builds the library and runs the unit tests in one step. The README gives both configurations:

sh
./unit_tests Debug
./unit_tests Release

The script will use ninja if it is installed, which the README says is not required but makes builds faster. On Windows there is a unit_tests.bat alongside it. If you are debugging rather than just building, the repository includes a VSCode launch configuration; you add breakpoints and run "Debug C++ Unit tests (lldb)", or "Debug C++ Unit tests (vsdbg)" on Windows.

For adding a test case, the flow is fixture first. Put an HTML file in gentest/fixtures, then install the generator dependencies and run it:

bash
yarn install
yarn gentest

The README specifies yarn classic for this step. After the run you should see new generated test cases derived from the layout Chrome produced for your fixture.

Where Yoga is the wrong tool

Yoga computes layout. It does not give you a scene graph, a styling system, hit testing, text shaping or accessibility. If you are looking for a UI toolkit, this is the wrong layer and you will spend your first week rebuilding the parts you assumed were included.

A second limitation is the test toolchain. Because expectations come from Chrome, regenerating tests pulls in a browser and a JavaScript workspace. That is fine inside Meta's infrastructure and fine for a contributor with a working yarn classic setup. It is friction for a downstream consumer who wants to patch a layout bug and prove the fix locally without touching the generator.

The README does not document a rollback path, a compatibility matrix across binding versions, or a deprecation policy for layout properties. If your product depends on a specific flexbox behaviour staying stable across upgrades, that stability is not something the README promises. You would be relying on the test suite continuing to catch regressions.

Finally, the release cadence visible in the release list is not fast: v3.1.0 in June 2024, v3.2.0 in December 2024, v3.2.1 shortly after. The repository itself was last pushed on 2026-09-17, so development activity is current even though tagged releases are sparse. If your integration needs frequent versioned drops, plan around that gap.

Yoga compared with Taffy and with hand-rolled layout

The closest alternative in the Rust ecosystem is Taffy, which implements flexbox and CSS Grid in Rust with a similar goal of being embeddable. The difference in approach is the reference for correctness. Yoga derives its expected results from rendering HTML fixtures in Chrome, which ties the test suite to a real browser's behaviour. Taffy's test strategy is its own; the point here is that Yoga's correctness argument rests on browser parity, and that argument only holds for the subset of flexbox the fixtures cover.

If your host language is Rust and you do not want a C++ dependency in your build, that difference matters more than any feature comparison. Pulling Yoga in means a C++20 toolchain and CMake in your build graph, which the repository confirms is how the core is built.

The other alternative is writing layout yourself. For a single row of equally sized items, that is a reasonable afternoon. For wrapping, baseline alignment, percentage sizing against an indefinite container, and the interaction between flex-grow and min-content, it is not. Yoga exists because that long tail is genuinely long, and the generated-fixture approach is an admission that the tail is longer than any one person's test file.

Maintenance cost, licensing and the upgrade question

Yoga is MIT licensed, and the repository carries both a LICENSE file and a separate LICENSE-examples file. The split matters if you plan to copy code out of the examples or the website directory: check which file covers the material you are taking. This is not legal advice; read both files before you vendor anything.

Upgrade cost is dominated by the binding, not the core. If you consume yoga-layout from npm or com.facebook.yoga:yoga from Maven Central, your upgrade is a version bump and whatever the layout tests in your own project catch. If you vendor the C++ source, you own the CMake integration, the C++20 requirement and the compiler-version floor that comes with it.

The formatting story is worth knowing before you send a patch. The root package.json defines format, format-check, lint and tsc scripts, and the format script fans out to four formatters: clang-format for C++, Prettier for JavaScript and Markdown, ktfmt for Kotlin, and a Python formatter. Running yarn format-check before opening a pull request is cheaper than having CI tell you the same thing. The repository was last pushed on 2026-09-17, so you are contributing to a live tree, not a frozen one.

Editorial conclusion

Adopt Yoga when you are writing a renderer, a terminal UI, a PDF generator or a native view system and you want the browser's flexbox rules rather than a layout algorithm of your own. Do not adopt it if you need a widget toolkit or a styled component layer; Yoga computes positions and sizes and nothing else, and the README documents no rollback path for a layout that comes out wrong. Before committing, verify three things: that the binding you need is published for your language, that your toolchain can build C++20 with the CMake logic in the repository, and whether the generated fixtures in gentest/fixtures cover the node structures you actually lay out.

Frequently asked questions

What is Yoga in React Native?

Yoga is the embeddable flexbox layout engine that React Native uses to compute the position and size of its views. It is written in C++20 with bindings for multiple languages, and the README describes it as targeting web standards, so flexbox behaviour matches what a browser would do.

How do I install Yoga from npm or Maven Central?

The JavaScript binding is published on npm as yoga-layout, and the Java binding is published on Maven Central as com.facebook.yoga:yoga. For C++ consumers the README points at vcpkg, noting that Yoga is part of the vcpkg collection of ports and that stale versions should be reported on the vcpkg repository.

How do I build Yoga and run its unit tests?

The repository provides a wrapper script. Running ./unit_tests Debug or ./unit_tests Release builds the main library and runs the unit tests; the script uses ninja if it is installed, which the README says is not required but makes builds faster.

How do I add a new layout test to Yoga?

Add an HTML fixture to gentest/fixtures, then run yarn install and yarn gentest from the yoga directory. The generator renders the fixture in Chrome and uses the resulting layout as the expected result for the generated C++ test, and the README specifies yarn classic for the generator dependencies.

Can I debug Yoga's C++ unit tests with breakpoints?

Yes. The repository includes a VSCode launch.json configuration. You add breakpoints and run "Debug C++ Unit tests (lldb)", or "Debug C++ Unit tests (vsdbg)" on Windows.

Official sources

  1. License: MIT
  2. Project website
  3. react/yoga on GitHub
  4. README
  5. Releases
Add this badge to your README

If you maintain this project, the badge below links readers to this analysis and shows its maintenance status from the daily GitHub snapshot. Paste the markdown into your README; add ?metric=license or ?metric=stars to the image URL for a different field.

Add this badge to your README

markdown
[![Hysen Labs](https://hysenlabs.com/badge/react-yoga.svg)](https://hysenlabs.com/projects/react-yoga)