twake-react-conventions

Use when writing, reviewing, or refactoring React components in Twake/Cozy frontend projects. Enforces functional components, React.memo usage, event handler naming, no inline styles, and twake-mui first with cozy-ui as fallback (never raw Material-UI).

linagora/twake-guidelines3 installsMITSynced Aug 22

Works with

Claude CodeCursorCodex CLIGitHub CopilotGemini CLI
---
name: twake-react-conventions
description: Use when writing, reviewing, or refactoring React components in Twake/Cozy frontend projects. Enforces functional components, React.memo usage, event handler naming, no inline styles, and twake-mui first with cozy-ui as fallback (never raw Material-UI).
license: MIT
---

# React Conventions (Twake / Cozy)

Apply these rules whenever you are writing or modifying React code in a Twake or Cozy frontend project.

## Components

- **Use functional components only** for any new code. Do not write class components.
- **One component per file** when the component is non-trivial.

Export, async, naming, and other language-level rules follow `twake-javascript-conventions` (and `twake-typescript-conventions` for `.tsx`) — including **named exports only, never `export default`**.

## Performance

- Use `React.memo` **only** for medium-to-large components that render frequently with identical props. Don't memo everything — it adds cost and complexity.
- Prefer `useMemo` / `useCallback` only when profiling shows a need, or when passing stable references to memoized children.

## Event handlers

- **Named handlers** over inline arrow functions in JSX when the handler is non-trivial.
  ```jsx
  // ✅ Good
  const handleSubmit = () => { ... }
  return <form onSubmit={handleSubmit} />

  // ❌ Avoid for non-trivial logic
  return <form onSubmit={() => { /* lots of logic */ }} />
  ```
- Name handlers `handleX` or `onX` consistently within a file.

## UI library

Twake / Cozy React projects use two in-house component libraries. **Never import Material-UI (`@mui/material`) directly in application code** — always go through one of these design systems.

| Library | Based on | Status | Role |
|---|---|---|---|
| [`twake-mui`](https://github.com/linagora/twake-ui) | MUI **v7** | Modern, early stage (limited catalogue) | **First choice** — use whenever the component you need exists here |
| [`cozy-ui`](https://github.com/cozy/cozy-ui) | MUI **v4** | Mature, outdated, very complete | **Fallback** when `twake-mui` does not yet provide the component or variant |

This order reflects the soft migration toward MUI v7: reach for `twake-mui` first, and only drop back to `cozy-ui` when `twake-mui` is missing what you need.

### When neither library has what you need

**Do not** reach for raw MUI, do not invent a workaround, do not copy-paste a stripped-down version, and do not fall back to inline styles.

**Stop and ask the user** what to do. Typical options they may choose:
- Add the missing component/variant to `twake-mui` (preferred) or `cozy-ui` first, then use it
- Use a close-enough existing component with documented trade-offs
- Escalate to the design-system maintainers

Phrase the question concretely: name the component you need, the variant or prop that is missing, whether you already checked both libraries, and the place where you would use it.

## Styling

**No inline styles.** Do not use the `style={{...}}` prop in JSX and do not inline CSS strings. Styling must go through the design system:

```jsx
// ❌ Forbidden
<div style={{ padding: 16, color: 'red' }}>...</div>

// ✅ Good — use a cozy-ui / twake-mui component with its documented props
<Stack spacing={2}>
  <Typography color="error">...</Typography>
</Stack>
```

Same rule as the UI library section: if `cozy-ui` / `twake-mui` does not expose the style variant you need, **ask the user** — do not fall back to inline styles or raw MUI `sx`.

## Testing

See the dedicated `twake-frontend-testing` skill for testing rules (testing-library, `data-testid`, `queryBy` patterns, colocated `*.spec.jsx` files, no snapshots).

## Dependency rules for libraries

If you are working inside a shared library (not an app):
- `react` and `react-dom` go in `devDependencies` **and** `peerDependencies` — never in `dependencies`.
- Do not import Material-UI at all.
- Do not add cross-dependencies between `cozy-*` libraries.
- **Never import `cozy-flags` in a library.** Feature flags (`flag('...')`) are an app-level concern. A library component that needs flag-gated behavior must expose a boolean prop with a sensible default; the app reads the flag and passes it as the prop value.

```jsx
// ❌ Library reads the flag directly
import flag from 'cozy-flags'
const FederatedModal = () =>
  flag('drive.federated') ? <A /> : <B />

// ✅ Library exposes a boolean prop
const FederatedModal = ({ isFederatedMode = false }) =>
  isFederatedMode ? <A /> : <B />

// ✅ App consumes the flag and feeds the prop
import flag from 'cozy-flags'
<FederatedModal isFederatedMode={flag('drive.federated')} />
```

More Design Systems skills

stitch-design-taste

leonxlnx/taste-skill

Semantic Design System Skill for Google Stitch. Generates agent-friendly DESIGN.md files that enforce premium, anti-generic UI standards — strict typography, calibrated color, asymmetric layouts, perpetual micro-motion, and hardware-accelerated performance.

265.6k

figma

heygen-com/hyperframes

Import Figma content into a HyperFrames composition — rendered assets, brand tokens, components, storyboard sections → reconstructed motion (frames read as states, not slides) (REST/CLI), connector-assisted motion when available, and shaders from a connector or native export. Use when the user pastes a figma.com link or asks to bring a Figma design, frame, logo, brand, or animation into a video/composition.

101.8k

image

coreyhaines31/marketingskills

When the user wants to create, generate, edit, or optimize images for marketing — blog heroes, social graphics, product mockups, profile banners, listing visuals, or brand assets. Also use when the user mentions 'AI image generation,' 'generate an image,' 'create a graphic,' 'product mockup,' 'hero image,' 'social media graphic,' 'banner image,' 'cover photo,' 'profile banner,' 'listing screenshot,' 'Flux,' 'Flux Kontext,' 'Midjourney,' 'DALL-E,' 'GPT Image,' 'ChatGPT Images,' 'Ideogram,' 'Gemini image,' 'Nano Banana,' 'Recraft,' 'Stable Diffusion,' 'Canva,' 'Figma,' 'image optimization,' 'compress images,' 'WebP,' or 'OG image.' Use this for general-purpose marketing image creation and optimization. For paid ad image creative and platform-specific ad specs, see ad-creative. For video production, see video.

62.9k

← All Design Systems skills

Check your AI visibility

One URL in, a 0–100 score and the exact fixes out.

RUN THE CHECK

Browse all the tools

15 tools across six categories
13 of them never send your data anywhere

Free · No signup · No trial clock

SEE THE DIRECTORY