static/app/components/core/overview/contributing.mdx
This guide is for engineers and designers at Sentry who want to contribute to Scraps.
Scraps is Sentry's design system. It includes core primitive React components, hooks, design tokens, and patterns that we use to build Sentry's UI. Keep in mind that while we strive to have a 1:1 mapping between Figma and code, some gaps and inconsistencies currently exist.
Core components (static/app/components/core/*) are the foundational building blocks of Sentry's UI. The Design Engineering team maintains @sentry/scraps components to ensure consistency, accessibility, and quality across the product.
You can contribute the following without asking first:
For these contributions, open a PR directly with your changes.
Please ask first in #discuss-design-engineering before working on:
core/*We're still developing a formal request process, but for now, share your proposal in Slack to get feedback before investing time in implementation.
All changes to core components:
@CODEOWNERS.mdx stories)To work with core components locally, you'll need a frontend development environment. If you don't have one set up yet, follow the frontend development setup guide.
Once you have a local development environment setup, run pnpm run dev-ui to run the dev server, or pnpm run dev-ui-storybook to run the dev server and generate component types at build time (comes at the expense of slower dev server startup).
Design tokens are the design system's atomic values: colors, spacing, typography, motion, and more. They're defined in the static/app/utils/theme/scraps/ directory.
Do not directly update design tokens. These files are generated from our Figma library. Instead, request token changes from the Design Engineering team, who will run an import.
#discuss-design-engineering with your requestIf you're maintaining design tokens, Figma is our single source of truth. Tokens live in the 🐦 Primitives library as Variables.
Export from Figma using the TokensBrücke plugin
export.json in the tokens packageImport and build in the design-engineering repo:
pnpm --filter @scraps/tokens run import
pnpm --filter @scraps/tokens run build
Deploy to Sentry by copying /packages/tokens/dist to static/app/utils/theme/scraps/ in the getsentry/sentry repository
For detailed instructions, see the tokens CONTRIBUTING.md in the design-engineering repo.
Stories is the documentation system for Scraps. Each story describes how to use a React component or hook, its public API, intended behavior, and common usage patterns.
Stories for core components are owned by the Design Engineering team. Stories for product-specific components are maintained by the teams responsible for those product areas. However, all documentation is a shared responsibility—if you notice a mistake or omission while reading a story, consider it an opportunity to leave the docs in better shape than you found them.
The easiest way to document a component is to create an .mdx file next to the component. For a new myButton component, the file should be named myButton.mdx.
components/
└── myButton.tsx
└── myButton.mdx
All .mdx files should include frontmatter with metadata about the component. The following fields are supported:
---
title: My Button
description: MyButton is a clickable element that triggers an action.
source: '@sentry/scraps/myButton'
# Optionally include links to Figma, source code, accessibility resources, and further resources:
resources:
figma: https://www.figma.com/design/...
js: https://github.com/getsentry/sentry/...
a11y:
WCAG 1.4.3: https://www.w3.org/TR/WCAG22/#contrast-minimum
WAI-ARIA Button Practices: https://www.w3.org/WAI/ARIA/apg/patterns/button/
reference:
DTCG Glossary: https://www.designtokens.org/glossary/
---
Required fields:
title: The display name of the component or patterndescription: A brief description of what the component doesOptional fields:
layout: Use document for principle/pattern pagessource: Path to the component source codestatus: Use in-progress for incomplete documentationresources: Links to related resources (valid keys are figma, js, a11y, and reference)Components can include auto-generated API documentation using our custom type-loader. Export an object named documentation with the loaded types:
export const documentation = import('!!type-loader!@sentry/scraps/button/linkButton');
[!TIP] The inline loader syntax looks unusual, but it's required for Rspack to process the types correctly. Note that the documentation will not be generated unless you run
pnpm run dev-ui-storybook.
For a complete example, see the button.mdx file.
Use clear heading hierarchy to make documentation scannable:
# for major sections## for subsections### for specific examples or variationsShow real-world usage examples with code snippets:
import {Button} from 'sentry/components/core/button';
function Example() {
return <Button onClick={handleClick}>Click Me</Button>;
}
Include sections for:
Emphasize important information with callouts:
> [!TIP]
> Helpful tips and best practices
> [!WARNING]
> Important warnings or limitations
Stories documentation is a living system. When you encounter documentation that could be improved:
.mdx fileDon't hesitate to make improvements, even to documentation you didn't write originally.
The Design Engineering team is always available to answer questions and provide guidance on contributing to Scraps.
#discuss-design-engineering on Slack#discuss-design-engineering#discuss-design-engineeringAll code for Scraps, including the Stories framework, is built and maintained by Sentry's Design Engineering team on behalf of all teams. Contributions are always welcome!