fluentui-react-native / foundation-compose
AGENTS.md1.4k starsChanged 6 months agoMITView on GitHub
These instructions apply to packages/deprecated/foundation-compose and to work on components that use @uifabricshared/foundation-compose. They describe the legacy/v0 framework only. Do not use this pattern for a new component unless the task explicitly requires v0 compatibility. Treat code as v0 when several of these are present: - imports from @uifabricshared/foundation-compose, foundation-composable, foundation-settings, or foundation-tokens; - a descriptor such as IButtonType with props, tokens, slotProps, optional state, and optional statics; - compose<IButtonType>({...}), IUseComposeStyling<IButtonType>, ISlots<...>, and mergeSettings(...); - settings shaped as { tokens,…
Trending
Quiet since March.about the whole repository
Who's talking about microsoft/fluentui-react-native
- microsoft/rushstack“[rush] Why does many Microsoft open-source projects not use rush.”GitHub · Oct 31, 2021 · 3 reactions
- microsoft/react-native-macos“chore: migrate to changesets”GitHub · Feb 25, 2026 · 1 reactions
- @migueldv90.bsky.social“Microsoft is developing a UI library, but it’s still in Alpha.”Bluesky · Dec 21, 2024 · 1 likes
- microsoft/react-native-macos“docs: add explainer for gotchas with NSView based native components”GitHub · Aug 11, 2023 · 1 reactions
- microsoft/.github“ci: Add 2 bots to CLA policies”GitHub · Mar 5, 2026
The biggest 5 of 24 mentions linking to the repository that our crawl found. Each line is their own headline.
See all 24
Talked about on GitHub and Bluesky (24 times).
On GitHub · 23
- Oct 31, 2021[rush] Why does many Microsoft open-source projects not use rush. — microsoft/rushstack3 reactions · 6 comments
- Feb 25, 2026chore: migrate to changesets — microsoft/react-native-macos1 reaction · 1 comment
- Aug 11, 2023docs: add explainer for gotchas with NSView based native components — microsoft/react-native-macos1 reaction · 1 comment
- Mar 5, 2026ci: Add 2 bots to CLA policies — microsoft/.github0 reactions · 1 comment
- Sep 16, 2025Update Fabric branch to main — chrisglein/artificial-chat0 reactions
18 more on GitHub
- Dec 18, 2024Update to 0.76 — chrisglein/artificial-chat0 reactions
- Apr 24, 2024Add FURN (fluent-ui-react-native) to Gallery — microsoft/react-native-gallery0 reactions · 2 comments
- Aug 11, 2023bug: Cannot install drivers when using workspace:* with yarn 3 — appium/appium0 reactions · 5 comments
- Aug 8, 2023Files are generated under the wrong folder if no `node_modules` folder exists — microsoft/react-native-test-app0 reactions
- May 9, 2023Retarget Community Module's TargetPlatformMinVersion — microsoft/react-native-gallery0 reactions · 1 comment
- May 3, 2023Change the UI library to TUI or another — ZOPH3/WhatsThat_TS0 reactions
- May 2, 2023Move react-native-svg from dependencies to peerDependencies — microsoft/fluentui-system-icons0 reactions · 3 comments
- Apr 3, 2023Add fluent-ui-react-native controls and update various visual styles — chrisglein/artificial-chat0 reactions · 2 comments
- Mar 31, 2023Use fluent-ui-react-native controls — chrisglein/artificial-chat0 reactions · 2 comments
- Dec 31, 2022keyUpEvents/keyDownEvents check `code`, not `key` — microsoft/react-native-windows0 reactions · 8 comments
- Dec 14, 2022Setting the testID on the view does not prevent it from being removed from the view hierarchy — microsoft/react-native-windows0 reactions
- Dec 14, 2022Setting the testID on the view does not prevent it from being removed from the view hierarchy — microsoft/react-native-macos0 reactions · 1 comment
- Nov 15, 2022Remove faulty logic in ScrollView — microsoft/react-native-macos0 reactions · 2 comments
- Oct 31, 2022Aligning Avatar color hash color algorithm with web — microsoft/fluentui-apple0 reactions · 6 comments
- Oct 25, 2022fix(jest-preset): `@office-iss/react-native-win32` needs to be transformed — microsoft/rnx-kit0 reactions
- Oct 14, 2022Pressable unnecessarily re-renders if `disabled` prop is true — react/react-native0 reactions · 4 comments
- Aug 5, 2021Bumping Lage from 0.31.0 to 0.32.0 broke our monorepo's pipeline — microsoft/lage0 reactions · 3 comments
- May 14, 2020Setup E2ETest for React Native Win32/NetUI — microsoft/react-native-windows0 reactions · 4 comments
On Bluesky · 1
- Dec 21, 2024Microsoft is developing a UI library, but it’s still in Alpha. — @migueldv90.bsky.social1 likes and repost
Where files are headingNew AGENTS.md files have more rules about keeping secrets out of the code, and fewer about checking a change actually works.
Of the AGENTS.md files we read, the 11,773 first seen in the last six months, against the older ones: the kind of rule that gained most share, and the kind that lost most. About files like this in general, not this one, and an estimate, since a kind is a pattern in the words.
In this repository17 other files it gives its agents.
- AGENTS.mdAGENTS.md
- apps/storybook/AGENTS.mdAGENTS.md
- packages/agentic/components/AGENTS.mdAGENTS.md
- packages/agentic/components/src/AGENTS.mdAGENTS.md
- packages/agentic/components/src/components/AGENTS.mdAGENTS.md
- packages/agentic/components/src/primitives/AGENTS.mdAGENTS.md
- packages/agentic/desktop-driver/AGENTS.mdAGENTS.md
- packages/framework-base/AGENTS.mdAGENTS.md
- packages/framework-base/src/accessibility/AGENTS.mdAGENTS.md
- packages/framework/framework/AGENTS.mdAGENTS.md
- CLAUDE.mdCLAUDE.md
- .github/copilot-instructions.mdCopilot instructions
- agentic-component-authoringSkill
- agentic-component-contract-authoringSkill
- agentic-component-optimizationSkill
- agentic-storybook-developmentSkill
- fix-security-issuesSkill
The file
Show its rules and text
We split this AGENTS.md into the rules it gives an agent
15 rules. About 0 are common, 3 are distinctive, and 12 are very specific to this project.
≈0
Common · estimate
Many files like this have a rule of this kind.
≈3
Distinctive · estimate
This author's own choices. Worth a look.
12
Very specific
Tied to their project's names, files or tools. Probably skip.
- Common
- Distinctive
- Very specific
- Distinctive: line 10
Treat code as v0 when several of these are present:
- Very specific: line 36
run usePrepareProps for hooks, state, refs, and instance-specific props.
- Very specific: line 37
call the hook-free render function with prepared Slots.
- Very specific: line 107
Put / @jsxImportSource @fluentui-react-native/framework-base */ first in files that render callable Slots with JSX.
- Very specific: line 117
Use _precedence to define state application order and _overrides for state-specific settings.
- Distinctive: line 132
When a slot is itself composed and supports a token, token processing can forward that token to the child instead of producing a …
- Very specific: line 135
Put theme/default/state values in settings and token-derived style in styles.
- Very specific: line 151
Do not introduce forwardRef or a new public ref convention into an established v0 API without an explicit migration requirement.
- Very specific: line 156
Use normal React Native resolution for .android.tsx, .macos.tsx, .windows.tsx, and .win32.tsx, and for platform settings files.
- Very specific: line 165
Do not rewrite v0 code to @fluentui-react-native/composition, modern @fluentui-react-native/framework, or framework-base …
- Very specific: line 168
Do not apply v1 slot types, flat state tokens, useTokens, or the new .customize({ token: value, state: {...} }) shape to v0 code.
- Very specific: line 170
Do not “simplify” away mergeSettings, the settings name entry, override lookup, prop filters, token key lists, or the split prepare/render …
- Very specific: line 173
Prefer surgical fixes. Migration to v1 is a separate task and must account for documented prop, token, slot, and export differences such as …
- Distinctive: line 179
Run the smallest package-scoped checks covering the change:
- Very specific: line 193
Update existing snapshots only after reviewing the rendered slot tree.
≈ “Common” is an estimate: at least 1 in 5 of the 16,595 AGENTS.md files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.
Files
Legacy v0 component authoring
These instructions apply to packages/deprecated/foundation-compose and to work
on components that use @uifabricshared/foundation-compose. They describe the
legacy/v0 framework only. Do not use this pattern for a new component unless the
task explicitly requires v0 compatibility.
Recognizing v0 code
Treat code as v0 when several of these are present:
- imports from
@uifabricshared/foundation-compose,foundation-composable,foundation-settings, orfoundation-tokens; - a descriptor such as
IButtonTypewithprops,tokens,slotProps, optionalstate, and optionalstatics; compose<IButtonType>({...}),IUseComposeStyling<IButtonType>,ISlots<...>, andmergeSettings(...);- settings shaped as
{ tokens, root, ...slots, _overrides, _precedence }; - an implementation under
deprecated/orlegacy/, or an old un-suffixed export beside a newerV1export.
Representative implementations are
packages/components/Button/src/deprecated/Button.tsx,
packages/components/Checkbox/src/deprecated/Checkbox.tsx,
packages/components/Link/src/legacy/Link.tsx,
packages/components/Persona/src/Persona.tsx, and
packages/components/Stack/src/Stack.tsx.
Framework model and public API
compose combines the lower-level composable, themed-settings, settings, and
token systems. Its phases are:
- resolve and cache layered
settings; - resolve token props into cached slot props/styles through
styles; - run
usePreparePropsfor hooks, state, refs, and instance-specific props; - call the hook-free
renderfunction with preparedSlots.
The package publicly exports compose, initializeStyling, and the compose
option/return/settings/styling and type-extraction types listed in src/index.ts.
The returned component exposes __composable, .compose(options), and
.customize(...settings). Prefer the strongly typed component methods:
.compose(...)replaces or augments behavior, slots, styles, settings, or render without adding a React wrapper. Settings are appended to the base settings. Seepackages/components/Button/src/deprecated/PrimaryButton/PrimaryButton.ts..customize(...)only appends old-style settings entries. Its input retainstokens,_overrides,_precedence, and slot-prop keys; it is not the newer flat token customization format.staticsattaches subcomponents, as inStack.Item.
The exported two-argument compose(options, base) form is the underlying API;
use Base.compose(options) when the base is already a typed composed component.
initializeStyling is framework infrastructure that compose installs
automatically, not a routine component authors normally call.
Component shape
Define a shared descriptor type and keep slot names aligned:
interface IExampleType {
props: IExampleProps;
tokens: IExampleTokens;
slotProps: IExampleSlotProps; // must contain root
state: IExampleState;
}
export const Example = compose<IExampleType>({
displayName: exampleName,
settings,
usePrepareProps,
render,
slots: { root: View, content: Text },
styles: { root: [backgroundColorTokens], content: [textTokens] },
});Typical files are <Component>.types.ts, <Component>.settings.ts,
<Component>.tokens*.ts, <Component>.tsx, index.ts, and colocated Jest
tests/snapshots. Preserve existing public I-prefixed types, deprecated exports,
display names, prop names, and v0/v1 aliases.
For a one-slot component, compose supplies default preparation and rendering:
it applies styling and user props to root. See
packages/components/Text/src/deprecated/Text.tsx and
packages/components/Stack/src/StackItem/StackItem.tsx. Multiple slots require
an explicit render. Once custom usePrepareProps is supplied, it must put the
public/native props on the appropriate slot; the framework does not do that
automatically.
Slots and rendering
slotPropsis a named props collection with a requiredroot.- Define each slot as a component/string or as
{ slotType, filter }. Use existing filters such asfilterViewProps,filterTextProps, andfilterImagePropsso component-only/token props do not reach native views. - Merge prepared props with styling, normally
mergeSettings(useStyling(userProps, lookup), { root: rootProps, ... }). Later entries win, including merged styles and class names. - Render prepared slots as
<Slots.root>/<Slots.content>. Their prepared props are already captured; pass only additional render-time props in JSX. - Children are removed before preparation and supplied to
renderas...children. Decide explicitly where they belong, as Button, Link, and Stack do. Conditional slot rendering is safe because all hooks already ran. - Put
/** @jsxImportSource @fluentui-react-native/framework-base */first in files that render callableSlotswith JSX. This pragma supports the legacy slot runtime; it does not make the component a modern framework-base pattern.
Settings, tokens, and styling
- Type settings as
IComposeSettings<IExampleType>. Entries are layered in array order and may be a settings object, a theme settings name string, or a(theme) => settingsfunction. Keep objects/functions stable and never mutate cached settings. - Use
_precedenceto define state application order and_overridesfor state-specific settings; nested overrides are supported. Settings names such asbuttonNameload theme-provided component settings. useStyling(props)uses props as the default override mask. For derived interaction state, pass an override lookup function or mask, as in legacy Button, Checkbox, and Link.- Declare token-to-slot processing in
styles. Reuse operation sets such asbackgroundColorTokens,borderTokens,foregroundColorTokens, andtextTokens; use{ source, target, lookup }for mappings/theme lookup. - For component-specific calculations, use
styleFunctionand list every token key that affects the result. Seepackages/components/Persona/src/Persona.tokens.root.ts,packages/components/Persona/src/Persona.tokens.texts.ts, andpackages/components/Stack/src/Stack.tokens.ts. Accurate key lists are required for memoization. - When a slot is itself composed and supports a token, token processing can forward that token to the child instead of producing a parent-owned style. Preserve compatible child token contracts when replacing composed slots.
- Put theme/default/state values in settings and token-derived style in
styles. Put highly variable values such as text, accessibility props, handlers, sources, and refs intousePreparePropsslot props.
State, hooks, and refs
usePreparePropsanduseStylingare hook phases: call them on every render and never conditionally. Hooks, context, controlled/uncontrolled state, and interaction hooks belong inusePrepareProps.- Return
{ slotProps, state };stateis simply the typed payload forrender, not necessarily React state. Keeprenderhook-free. - Preserve the v0
componentRefAPI where present. Convert it to the native rootrefduring preparation, commonly withuseViewCommandFocus; type ref-bearing roots withReact.PropsWithRef<...>. For imperative native APIs, use an internal native ref plususeImperativeHandle, as inpackages/agentic/native-core/src/legacy/callout/Callout.tsx. - Do not introduce
forwardRefor a new publicrefconvention into an established v0 API without an explicit migration requirement.
Platform-specific implementations
Use normal React Native resolution for .android.tsx, .macos.tsx,
.windows.tsx, and .win32.tsx, and for platform settings files. Keep the same
public descriptor/props across variants while allowing different native slots
and preparation logic. Examples include deprecated Button on Android and
RadioButton on macOS/Win32. Keep imports from platform React Native forks inside
their platform files, per the repository root guidance.
Legacy boundaries
- Do not rewrite v0 code to
@fluentui-react-native/composition, modern@fluentui-react-native/framework, or framework-basephasedComponent/directComponent/useSlotpatterns as part of maintenance. - Do not apply v1 slot types, flat state tokens,
useTokens, or the new.customize({ token: value, state: {...} })shape to v0 code. - Do not “simplify” away
mergeSettings, the settings name entry, override lookup, prop filters, token key lists, or the split prepare/render phases; each participates in compatibility, composition, or caching. - Prefer surgical fixes. Migration to v1 is a separate task and must account for
documented prop, token, slot, and export differences such as
packages/components/Button/MIGRATION.md.
Validation
Run the smallest package-scoped checks covering the change:
yarn workspace @uifabricshared/foundation-compose build
yarn workspace @uifabricshared/foundation-compose lintFor behavior changes, also test/build the owning consumer package, for example:
yarn workspace @fluentui-react-native/button test
yarn workspace @fluentui-react-native/button buildUpdate existing snapshots only after reviewing the rendered slot tree. Changes
to settings override/merge semantics or token processing also require the
foundation-settings or foundation-tokens unit tests respectively.
Does it work?
Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.
No reviews yet
People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.
- It worked
- Partly
- It didn't
Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.
Your trail
Files you open will collect here, so you can find them again.
Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.
Now do this for your own.
Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.

