# General Translation React SDKs (gt-react, gt-next): Branch
URL: https://generaltranslation.com/en-GB/docs/react/reference/components/branch.mdx
---
title: Branch
description: Render content conditionally based on a value with General Translation gt-react. API reference for Branch.
---
The `` component adds conditional logic to a translation. You pass a value to `branch`, and it renders the matching child prop.
*Available in `gt-react`, `gt-next`, `gt-tanstack-start`, and `gt-react-native`. Examples import from `gt-react`; import from your framework's package instead.*
## Overview [#overview]
Provide a `branch` value and a child prop for each possible value.
```tsx
The user is active.
}
inactive={The user is inactive.
}
/>
```
*Note: place `` inside a [``](/docs/react/reference/components/t) to translate the branches, and wrap any dynamic values within them in a variable component such as [``](/docs/react/reference/components/var).*
## How it works [#how-it-works]
* **Value matching.** The `branch` value is matched against the prop keys you provide. The matching prop's content renders.
* **Fallback.** When `branch` is omitted, or its value does not match any prop key, `children` renders as a fallback. `` never throws.
## Props [#props]
| Prop | Description | Type | Optional | Default |
| ----------------------- | ---------------------------------------- | ----------------------------- | -------- | ------- |
| [`branch`](#branch) | The value that selects the content. | `string \| number \| boolean` | Yes | — |
| [`children`](#children) | Fallback content when no branch matches. | `ReactNode` | Yes | — |
| [`[value]`](#value) | Content for a specific branch value. | `ReactNode` | Yes | — |
### `branch` [#branch]
**Type** `string | number | boolean` · **Optional**
The value used to select which branch renders. When `branch` is omitted or its value does not match any branch prop key, `children` renders as the fallback instead.
### `children` [#children]
**Type** `ReactNode` · **Optional**
Fallback content rendered when no branch prop matches the `branch` value.
### `[value]` [#value]
**Type** `ReactNode` · **Optional**
A prop for each possible branch value. Each key corresponds to a value of `branch`, and its content renders when that value is matched. A string is accepted in place of JSX.
## Examples [#examples]
```tsx title="BranchExample.tsx"
import { Branch } from 'gt-react';
export default function HairColor({ user }) {
return (
Their hair is dark.}
brown="Their hair is in the middle." // a plain string also works
blonde={Their hair is light.
}
/>
);
}
```
```tsx title="BranchExample.tsx"
import { Branch } from 'gt-react';
export default function HairColor({ user }) {
return (
Their hair is dark.}
brown={Their hair is in the middle.
}
blonde={Their hair is light.
}
>
Their hair is unknown.
// [!code highlight] fallback
);
}
```
```tsx title="BranchExample.tsx"
import { T, Branch, Var } from 'gt-react';
export default function HairColor({ user }) {
return (
Their hair is dark.}
brown={Their hair is in the middle.
}
blonde={Their hair is light.
}
>
Unhandled hair color: {user.hairColor}
// [!code highlight]
);
}
```
## Notes [#notes]
* Branch keys can be any string value that matches the `branch` prop, making `` adaptable to many use cases.
* Combine `` with [``](/docs/react/reference/components/t) and [variable components](/docs/react/guides/formatting-variables) for translated, dynamic content.
* For count-based content, use [``](/docs/react/reference/components/plural).