
Security News
Static vs. Runtime Reachability: Insights from Latioβs On the Record Podcast
The Latio podcast explores how static and runtime reachability help teams prioritize exploitable vulnerabilities and streamline AppSec workflows.
@consensys/ds3
Advanced tools
π§ Note: This package is under active development. While we're working hard to make it production-ready, please be aware that APIs and features may change. We welcome your feedback and contributions as we continue to improve!
π Ultimate cross-platform React components that feel native everywhere
Build breathtaking interfaces for both web and React Native with a single component library that respects each platform's conventions while providing a unified developer experience.
// One import. Any platform. Native everywhere.
import { Button, Input, Icon } from '@consensys/ds3';
π True Cross-Platform - Components work natively on web and React Native with platform-specific optimizations
π§ Framework Agnostic - Seamless integration with Vite, Expo and more through @consensys/ds3-config plugins
π§© Compound Components - Simple by default, infinitely customizable when needed
π Dual API - Use familiar web APIs or React Native patterns - your choice, no compromise
βΏ Accessibility Built-in - Ship inclusive experiences without extra effort
π¨ Consistent Design - Share color schemes and tokens across platforms
π Pluggable Styling - Tailwind CSS + NativeWind for unified styling that feels native everywhere
πΌοΈ Universal SVG - Use your favorite icon libraries seamlessly on any platform
pnpm add @consensys/ds3
For detailed framework setup and configuration, see the @consensys/ds3-config documentation.
DS3 UI gives you production-ready components for building modern interfaces:
DS3 UI is built on six powerful architectural patterns that work together to deliver exceptional developer and user experiences:
Components intelligently adapt to their environment while maintaining consistent APIs:
// Same import, same API, platform-perfect behavior
import { Input } from '@consensys/ds3';
// Works perfectly on web and native
<Input
placeholder="Enter your name"
color="primary"
/>
DS3 UI components follow a consistent organization pattern that enables cross-platform functionality:
File | Purpose |
---|---|
Component.tsx | React Native implementation |
Component.web.tsx | Web implementation |
Component.shared.tsx | Shared compound elements (Icon, Text, etc.) |
context.ts | State sharing for compound components |
styles.ts | Shared CVA styling definitions |
utils.ts | Dual-API handling |
types.ts | TypeScript type definitions |
index.ts | Named exports |
DS3 UI uses two main approaches to implement cross-platform components:
1. Custom Implementation
Most components like <Button />
, <Input />
, and <Icon />
use platform-specific implementations:
// Input.tsx (React Native specific)
export const Input = (props) => <TextInput {...props} />;
// Input.web.tsx (Web specific)
export const Input = (props) => <input {...props} />;
2. Primitives-Based Implementation
Some components build on existing accessibility primitives:
// Checkbox.tsx uses RN Primitives
import * as CheckboxPrimitive from '@rn-primitives/checkbox';
// Checkbox.web.tsx uses Radix UI
import * as CheckboxPrimitive from '@radix-ui/react-checkbox';
These leverage Radix UI (web) and RN Primitives (React Native) for consistent behavior and accessibility.
Simple by default, infinitely customizable when needed:
// Simple usage - clean and concise
<Button color="primary">
Sign Up
</Button>
// Advanced usage - full control over structure and styling
<Button variant="outline" color="primary" className="px-8 rounded-full">
<Icon icon={Mail} className="mr-2" />
<Text className="font-bold tracking-wide">Contact Us</Text>
<Spinner spinner={RefreshCw} className="ml-3 animate-spin" />
</Button>
Power features:
For a deeper dive into the pattern, see the Patterns.dev guide.
Consistent experience across multiple React frameworks:
// Works in React DOM (Vite)
// Works in React Native (Expo)
// Works in Next.js (coming soon)
import { Button, Input } from '@consensys/ds3';
Integration features:
Framework-specific optimizations are handled by @consensys/ds3-config plugins, allowing your components to work seamlessly in any React environment.
Ship accessible experiences without extra effort:
The library automatically maps accessibility props between platforms. Here are a few common examples:
Web Props | Native Props | Component |
---|---|---|
aria-disabled | accessibilityState.disabled | Button, Input |
aria-busy | accessibilityState.busy | Button, Input |
role="button" | accessibilityRole="button" | Button |
// Web accessibility
<Button
aria-disabled={isLoading}
aria-busy={isLoading}
role="button"
>
Submit
</Button>
// Native accessibility
<Button
accessibilityState={{
disabled: isLoading,
busy: isLoading
}}
accessibilityRole="button"
>
<Text>Submit</Text>
</Button>
One styling system, perfect everywhere:
// Consistent styling API across platforms
<Text
size="lg"
weight="bold"
color="primary"
className="underline opacity-90" // Works on web and native!
/>
Style features:
While Platform Adaptation handles the underlying implementation differences, Dual API gives you the freedom to write code in your preferred style. Whether you're a web developer or React Native developer, you can use the APIs you're most comfortable with.
Dual API features:
onClick
, onChange
, type
)onPress
, onChangeText
)π Web-only Development
onClick
, onChange
, type
)π± Native/Hybrid Development
onPress
, onChangeText
)β οΈ Never Mix APIs
// β INCORRECT: Using web props in native/hybrid code
<Button
onClick={() => {}} // Will be ignored on native!
onPress={handlePress}
>
<Text>Mixed Props Button</Text>
</Button>
// β
CORRECT: π Web-only code can use web props
<Button
onClick={handleClick} // Perfectly fine in web-only code!
>
<Text>Web Button</Text>
</Button>
// β
CORRECT: π±π Native/hybrid code must use native props
<Button
onPress={handlePress}
>
<Text>Native Button</Text>
</Button>
For hybrid applications, the library automatically maps native props to web props. This one-way mapping ensures React Native code works seamlessly on web. Here are a few common examples:
Native Props | Web Props | Component |
---|---|---|
onPress | onClick | Button |
onChangeText | onChange | Input |
secureTextEntry | type="password" | Input |
β οΈ Important Rules:
- Never use web props in native code - they will be silently ignored
- Never mix web and native props - choose one style and stick with it
The library provides platform-specific event types for type safety:
import type { WebClickEvent, NativePressEvent } from '@consensys/ds3';
// π Web events
<Button onClick={(e: WebClickEvent) => console.log(e.currentTarget)}>
Click Me
</Button>
// π± Native events
<Button onPress={(e: NativePressEvent) => console.log(e.nativeEvent)}>
<Text>Press Me</Text>
</Button>
Web Types | Native Types | Description |
---|---|---|
WebClickEvent | NativePressEvent | Button click/press events |
WebFocusEvent | NativeFocusEvent | Focus/blur events |
WebChangeEvent | NativeChangeEvent | Input change events |
Replace any component part with your own elements:
// Button as a link using asChild
<Button variant="solid" color="primary" asChild>
<a href="https://example.com">Visit Website</a>
</Button>
// Button as a router link
<Button variant="outline" color="secondary" asChild>
<Link to="/dashboard">Go to Dashboard</Link>
</Button>
The Slot pattern allows you to replace a component's default root element with your own custom element, while preserving all styling, behavior, and accessibility features.
When you pass asChild={true}
to a component:
Slot
component instead of its default elementSlot
captures all props from the parent componentThe rendered DOM with asChild
would be essentially:
<a
href="https://example.com"
class="bg-neutral-a11"
role="button"
>
Visit Website
</a>
Our components use different Slot implementations based on platform:
@radix-ui/react-slot
for DOM elements@rn-primitives/slot
for React Native componentsThis allows the same API to work seamlessly across platforms while respecting platform-specific behavior.
Slot power:
# Install dependencies
pnpm i
# Watch and build
pnpm dev
# Production build
pnpm build
We welcome contributions! Check out our Contributing Guidelines for detailed information on our development workflow, code standards, and how to submit changes.
MIT
FAQs
Consensys UI component library
The npm package @consensys/ds3 receives a total of 23 weekly downloads. As such, @consensys/ds3 popularity was classified as not popular.
We found that @consensys/ds3 demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago.Β It has 17 open source maintainers collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
The Latio podcast explores how static and runtime reachability help teams prioritize exploitable vulnerabilities and streamline AppSec workflows.
Security News
The latest Opengrep releases add Apex scanning, precision rule tuning, and performance gains for open source static code analysis.
Security News
npm now supports Trusted Publishing with OIDC, enabling secure package publishing directly from CI/CD workflows without relying on long-lived tokens.