MetaMask / MetaMask/metamask-design-system
Standardize RN twClassName API to string and use Pressable style callbacks for pressed state
Nobody has claimed this yet.
- Dominant language
- TypeScript
- Stars
- 37
- Forks
- 14
- Avg merge
- 1d 9h
- Merged PRs (30d)
- 60
Description
## Problem
`twClassName` typing is inconsistent across `@metamask/design-system-react-native`.
- `ButtonBase` supports `twClassName?: string | ((pressed: boolean) => string)`
- Most other components define `twClassName?: string`
- Interactive components mix patterns for pressed-state styling
This creates API ambiguity for consumers.
## Proposal
Standardize `twClassName` as **string-only** across RN component public APIs, and handle interaction states via React Native `Pressable` style callback with `tw.style(...)`.
### Target pattern
```tsx
style={({ pressed }) =>
tw.style(
"base classes",
pressed && "pressed classes",
twClassName,
)
}
```
## Scope
1. Audit RN component `twClassName` typings.
2. Keep `twClassName` type as `string` for public props.
3. Move pressed-state class computation into internal `style` callbacks.
4. Update `ButtonBase` typing/implementation as needed (including `style` typing alignment with `PressableProps["style"]` where appropriate).
5. Update docs/examples and tests.
## Acceptance Criteria
- RN components use consistent `twClassName?: string` API.
- Pressed-state behavior is preserved.
- Type definitions and runtime behavior are aligned.
- Tests and docs are updated.
## Related
- Jira: https://consensyssoftware.atlassian.net/browse/DSYS-515
- Epic context: https://consensyssoftware.atlassian.net/browse/DSYS-272
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by auditing the React Native components named in the issue, with particular attention to ButtonBase and its twClassName and style typings. Review how Pressable style callbacks and tw.style are used, then check the existing tests and docs/examples. Done means all public twClassName props are strings, pressed-state behavior remains intact, and types, tests, and documentation agree.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- react-native, typescript
- Domain
- design, mobile
- Issue type
- Refactor
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 45/100