Figma Design Implementation
Figma MCP Usage
- When a prompt includes a Figma link (
https://figma.com/...), use Figma MCP to open and inspect the design first. - If MCP cannot access the design (auth, permissions, network, or node issues), do not proceed or "imagine" the design. Stop and briefly explain why the MCP connection failed and what access is needed.
- Never implement UI "according to the design" without actually retrieving it via MCP (e.g., code, metadata, or screenshot) in this session.
- Use existing color tokens from this codebase's semantic HSLA system.
- Colors are defined in
lib/ui/theme/ThemeColors.tsand implemented inlib/ui/theme/darkTheme.ts. - In styled-components: use
getColor('tokenName')from@lib/ui/theme/getters. - As component props: use
ThemeColortype (e.g.,color="primary",bgColor="foreground"). - Key token categories:
- Text:
text,textSupporting,textShy - Semantic:
primary,success,danger,info,idle - Surfaces:
background,foreground,foregroundExtra,foregroundSuper - Buttons:
buttonPrimary,buttonSecondary,buttonNeutral - Never hardcode hex values from Figma. Always find the matching semantic token in
lib/ui/theme/darkTheme.ts. - When a Figma color doesn't match any token, stop and ask rather than guessing.
Mandatory Design-to-Code Mapping
Before writing ANY implementation code from a Figma design, you MUST extract and explicitly list a property mapping table in the plan. Do NOT skip this step. Do NOT guess or assume values.
1. Extract every property from every element
For EACH element in the Figma get_design_context output, extract:
- Colors: Read the exact color on every element (backgrounds, borders, text, icons). Map each to a codebase semantic color token. Do NOT reuse a "similar" token — use the exact one from the design.
- Spacing: Read the exact
gap,padding, andmarginpixel values between every pair of adjacent elements. Different gaps between different elements mean nested containers with different gap values — never flatten into a single gap. - Dimensions: Read exact
height,width,min-heightvalues. Cross-reference with codebase component size props (e.g., Buttonsize="md"= 46px height). - Typography: Read ALL of: font
size,weight,line-height,letter-spacing, andcolor. Map each toTextcomponent props. Do NOT skipweight— the default may differ from the design.
2. Present the mapping table in the plan
Use this format:
| Element | Figma Property | Figma Value | Code Prop/Token |
|----------------|---------------|----------------|----------------------------------|
| Icon | color | (from design) | getColor('contrast') |
| Message | color | (from design) | Text color="supporting" |
| Button | bg | (from design) | Button kind="secondary" |
| Button | height | 46px | Button size="md" |
| Icon<>Message | gap | 8px | VStack gap={8} |
| Message<>Btn | gap | 24px | VStack gap={24} |
3. Cross-reference component props with Figma values
When the design uses a known codebase component (Button, Text, etc.):
- Button kind: Match the Figma button's background and border colors against the theme tokens in
lib/ui/theme/darkTheme.ts. primary: usesbuttonPrimarysecondary: usesbuttonSecondaryoutlined: uses transparent background with border- Button size: Match the Figma button's
heightagainst codebase definitions: Button:sm(36px),md(46px)IconButton:xs(24px),sm(28px),md(32px),lg(40px),xl(52px)- Typography: Use the
Textcomponent from@lib/ui/text. - First check if the Figma style name matches a
TextVariant(see Typography Variants below). If it does, usevariant="..."instead of setting individual props. - If no variant matches, map font size to
sizeprop, weight toweightprop, and text color tocolorprop. - If Figma shows a named style that is NOT yet in
textVariantsRecord, create a new variant inlib/ui/text/index.tsxbefore using raw props. This keeps the design system in sync.
4. Never assume defaults
- Do NOT assume an icon color matches surrounding text color — check the icon's own color.
- Do NOT assume all gaps between elements are the same — check each pair individually.
- Do NOT assume a component size prop without checking the Figma height in pixels.
- Do NOT pick the "closest" value — use the exact value from the design.
Typography Variants
The Text component supports named variant props that map to Figma's named typography styles. Always use a variant when the Figma style name matches one in this table.
| Figma Style Name | variant prop | size | weight | line-height | letter-spacing |
|---------------------------|----------------|------|--------|-------------|----------------|
| Hero/H1 | h1Hero | 54 | 500 | 1.5 | — |
| Regular/H1 | h1Regular | 42 | 500 | 1.5 | — |
| Supplementary/Footnote | footnote | 13 | 500 | 1.385 | 0.06px |
Usage
// Figma shows "Supplementary/Footnote" style → use variant
<Text variant="footnote" color="shy">Description text</Text>
// Figma shows a style NOT in the table → create a new variant first
// 1. Add to TextVariant type in lib/ui/text/index.tsx
// 2. Add to textVariantsRecord with exact Figma values
// 3. Then use it: <Text variant="newVariant" color="...">
Rules
coloris always set separately via thecolorprop — variants do NOT include color (Figma typography styles and colors are independent).- When a Figma design uses a named typography style (visible in the Figma inspector as a style name like "Supplementary/Footnote"), you MUST use the corresponding variant.
- If the named style is missing from
textVariantsRecord, add it before proceeding. Do NOT use rawsize/weightprops to approximate a named style. - The
heightprop accepts both named presets (small,regular,large) and numeric line-height ratios (e.g.,1.385). Use the exact ratio from Figma when adding new variants.
Icon Sourcing
Figma MCP does not reliably export SVG icon paths. When implementing a design with icons:
- Check if the icon already exists in
lib/ui/icons/. Search by visual description or name. - If the icon does NOT exist, ask the user to provide the exact SVG from Figma. Say: "I need the SVG for [icon description]. Could you paste it from Figma?"
- Never approximate, invent, or use a "similar" icon. The exact SVG from the design must be used.
- When creating a new icon from user-provided SVG, follow the
svg-icon-patternskill.
Screen Layout
When implementing a full screen from a Figma design, always use ScreenLayout from lib/ui/layout/ScreenLayout/ScreenLayout.tsx. Do NOT manually compose PageHeader + PageContent + PageFooter.
API
import { ScreenLayout } from '@lib/ui/layout/ScreenLayout/ScreenLayout'
<ScreenLayout
title="Screen Title" // optional — centered in header
onBack={() => goBack()} // optional — shows back button (IconButton secondary lg)
footer={<Button>Action</Button>} // optional — sticky footer
>
{/* scrollable content */}
</ScreenLayout>
Props
| Prop | Type | Description |
|------------|----------------|-----------------------------------------------------------------------------|
| children | ReactNode | Main content — placed in a centered column (max 500px, 24px side padding) |
| title | ReactNode | Optional header title, centered |
| onBack | () => void | If provided, renders a back button in the header |
| footer | ReactNode | Optional sticky footer, same centered column width as content |
Behavior
- Header renders only when
titleoronBackis provided. - Content is scrollable; scrollbar appears on the right edge of the screen, not inside the centered column.
- Footer stays fixed at the bottom, outside the scroll area.
- Responsive: content is 345px on iPhone (393px screen), stretches on medium screens (extension popover), caps at 500px on wider screens.
Mapping Figma screens to ScreenLayout
When you see a Figma screen with a back chevron button and/or a centered title at the top:
onBack→ the back button callback (useuseNavigateBack()or a custom callback)title→ the centered header text
When you see a primary action button pinned at the bottom of the screen:
footer→ wrap the button in the footer prop
Everything between the header and footer is children.
Vertical centering
If children need to fill the available vertical space (e.g., a centered animation), wrap them in a VStack with flexGrow and justifyContent="center".
Background decorations
If the screen has a background decoration (gradient, pattern), wrap ScreenLayout in a positioned container and place the decoration as a sibling:
<Wrapper> {/* position: relative; height: 100% */}
<Gradient /> {/* position: absolute; z-index: 0 */}
<ScreenLayout onBack={...} footer={...}>
{/* content */}
</ScreenLayout>
</Wrapper>
Key Component References
Consult these files for implementation details:
- Screen Layout:
lib/ui/layout/ScreenLayout/ScreenLayout.tsx - Colors:
lib/ui/theme/ThemeColors.ts,lib/ui/theme/darkTheme.ts,lib/ui/theme/getters.ts - Typography:
lib/ui/text/index.tsx(includesTextVariantandtextVariantsRecord) - Buttons:
lib/ui/buttons/Button/index.tsx,lib/ui/buttons/IconButton/index.tsx - Layout:
lib/ui/layout/Stack/index.tsx(VStack, HStack) - Icons:
lib/ui/icons/(followsvg-icon-patternskill) - Pages:
lib/ui/page/(PageContent,PageHeader,PageFooter,PageSlice)