You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Always run tasks through nx (nx run, nx run-many, nx affected), never tools directly
Use nx_workspace tool to understand workspace architecture
Use nx_project_details tool to analyze specific project structure and dependencies
Use nx_docs tool for up-to-date Nx configuration guidance
Fluent UI — Agent Instructions
Instructions in this file are the source of truth, not existing code. This repo contains
legacy patterns (especially in v8 packages) that predate current standards. Never copy patterns
from existing code without verifying they match these instructions.
Critical Rules (never violate)
Never hardcode colors, spacing, or typography values. Always use design tokens from @fluentui/react-theme. See docs/architecture/design-tokens.md.
Never use React.FC. Always use ForwardRefComponent with React.forwardRef.
Never access window, document, or navigator directly. In v9 components, use useFluent_unstable() to get targetDocument and targetDocument.defaultView instead of document/window. For non-component code, use canUseDOM() from @fluentui/react-utilities.
Never add dependencies between component packages.react-button must not depend on react-menu. Shared logic goes in react-utilities or react-shared-contexts. See docs/architecture/layers.md.
Never skip beachball change files for published package changes. Run yarn beachball change.
V9 Component Template (the correct pattern)
// ComponentName.tsx — always ForwardRefComponent, never React.FCexportconstComponentName: ForwardRefComponent<ComponentNameProps>=React.forwardRef((props,ref)=>{conststate=useComponentName_unstable(props,ref);useComponentNameStyles_unstable(state);returnrenderComponentName_unstable(state);});// Styles — always use tokens, never hardcoded valuesimport{makeStyles}from'@griffel/react';import{tokens}from'@fluentui/react-theme';exportconstuseComponentNameStyles=makeStyles({root: {color: tokens.colorNeutralForeground1,padding: `${tokens.spacingVerticalS}${tokens.spacingHorizontalM}`,},});// mergeClasses — always preserve user className LASTstate.root.className=mergeClasses(classes.root,state.root.className,// always last);
Legacy Anti-Patterns (never copy these)
DO NOT copy patterns from packages/react/ (v8). That's maintenance-only legacy code using runtime styling, class components, and different APIs.
DO NOT use @fluentui/react imports for new v9 work. Use @fluentui/react-components.
DO NOT use mergeStyles or mergeStyleSets. Use Griffel makeStyles with design tokens.
DO NOT use IStyle or IStyleFunctionOrObject. Use Griffel's GriffelStyle type.
DO NOT use initializeIcons(). V9 uses @fluentui/react-icons with tree-shaking.
Exploration Guidance
packages/react-components/ has 74+ packages — search by specific component name, never read the full directory.
Use yarn nx show project <project-name> to understand a project's structure.
Map package names to paths: @fluentui/react-<name> → packages/react-components/react-<name>/library/src/.