Socket
Book a DemoInstallSign in
Socket

@consensys/ds3

Package Overview
Dependencies
Maintainers
17
Versions
7
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@consensys/ds3

Consensys UI component library

0.0.7
latest
Source
npmnpm
Version published
Weekly downloads
25
47.06%
Maintainers
17
Weekly downloads
Β 
Created
Source

Components

🚧 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';

✨ Standout Features

🌐 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

πŸš€ Get Started

pnpm add @consensys/ds3

For detailed framework setup and configuration, see the @consensys/ds3-config documentation.

πŸ“š Component Library

DS3 UI gives you production-ready components for building modern interfaces:

Core Components

  • Button - Pressable controls with multiple variants, states, and compositions
  • Checkbox - Selection controls with accessible states and custom icons
  • Heading - Semantic typography with consistent hierarchy across platforms
  • Icon - Universal SVG rendering with perfect platform adaptation
  • Input - Text fields with validation, icons, and platform-specific behaviors
  • Spinner - Loading indicators with customizable animations
  • Switch - Toggle controls with smooth animations
  • Text - Typography components with consistent styling everywhere

Form Components

  • Field - Foundational form fields with proper labeling and structure
  • Fields - High-level form controls with built-in validation and accessibility

Coming Soon

  • Dialog - Modal dialog experiences
  • Select - Dropdown selection menus
  • Avatar - User representation components
  • Card - Content containers with flexible layouts
  • Badge - Status indicators and counters

πŸ›οΈ Architectural Excellence

DS3 UI is built on six powerful architectural patterns that work together to deliver exceptional developer and user experiences:

1. 🌐 Platform Adaptation

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:

Component Architecture

FilePurpose
Component.tsxReact Native implementation
Component.web.tsxWeb implementation
Component.shared.tsxShared compound elements (Icon, Text, etc.)
context.tsState sharing for compound components
styles.tsShared CVA styling definitions
utils.tsDual-API handling
types.tsTypeScript type definitions
index.tsNamed exports

Implementation Strategies

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.

2. 🧩 Compound Components

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:

  • ⚑ Context sharing - Child components automatically inherit parent state
  • πŸŽ›οΈ Precise control - Position and style each element exactly how you want
  • 🎭 Dynamic rendering - Show/hide elements based on component state

For a deeper dive into the pattern, see the Patterns.dev guide.

3. πŸ”Œ Framework Integration

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 plugins - Easy setup with @consensys/ds3-config framework-specific plugins
  • 🧰 Configuration presets - Optimized defaults for each framework
  • πŸ”„ Shared APIs - Consistent component behavior regardless of framework

Framework-specific optimizations are handled by @consensys/ds3-config plugins, allowing your components to work seamlessly in any React environment.

4. β™Ώ Accessibility By Default

Ship accessible experiences without extra effort:

  • πŸ”€ ARIA mapping - Web attributes automatically map to native equivalents
  • ⌨️ Keyboard navigation - Full keyboard support on every platform
  • πŸ—£οΈ Screen reader optimization - Proper roles and states for assistive technology
  • 🌈 Focus management - Visual indicators and proper focus trapping

πŸ”„ Accessibility Prop Mapping

The library automatically maps accessibility props between platforms. Here are a few common examples:

Web PropsNative PropsComponent
aria-disabledaccessibilityState.disabledButton, Input
aria-busyaccessibilityState.busyButton, 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>

5. 🎨 Unified Styling

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:

  • 🌊 Tailwind + NativeWind - Use familiar Tailwind CSS classes everywhere through NativeWind
  • 🎭 Variants - Consistent styling API with class-variance-authority (CVA)
  • πŸŽ›οΈ Theme tokens - Shared design tokens for colors, spacing, and typography

6. πŸ”„ Dual API

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:

  • 🌐 Web-first development - Use familiar DOM APIs (onClick, onChange, type)
  • πŸ“± Native-first development - Use React Native APIs (onPress, onChangeText)
  • πŸ›‘οΈ Type safety - Full TypeScript support for both platforms
  • πŸ”„ Automatic conversion - Props map correctly between platforms
  • 🧠 Smart detection - Components adapt to how you use them

πŸ“‹ The Rules

  • 🌐 Web-only Development

    • Use ONLY web props (onClick, onChange, type)
    • Get full DOM access and browser features
    • Perfect for web-only applications
  • πŸ“± Native/Hybrid Development

    • Use ONLY native props (onPress, onChangeText)
    • Consistent with React Native patterns
    • Works across all platforms
  • ⚠️ 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>
    

πŸ”„ Prop Mapping

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 PropsWeb PropsComponent
onPressonClickButton
onChangeTextonChangeInput
secureTextEntrytype="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

πŸ“˜ Type-Safe Events

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 TypesNative TypesDescription
WebClickEventNativePressEventButton click/press events
WebFocusEventNativeFocusEventFocus/blur events
WebChangeEventNativeChangeEventInput change events

🎯 Platform Adaptation vs Dual API

  • Platform Adaptation: Handles the underlying implementation differences (DOM vs Native)
  • Dual API: Gives you the freedom to write code in your preferred style

7. πŸ”Œ Slot Pattern

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:

  • The component renders a Slot component instead of its default element
  • The Slot captures all props from the parent component
  • It applies those props to the first child element you provide
  • The child element becomes the new root, inheriting all behavior

The 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:

This allows the same API to work seamlessly across platforms while respecting platform-specific behavior.

Slot power:

  • 🎭 Style inheritance - Your elements inherit DS3 styling
  • πŸ”Œ Behavior injection - DS3 behaviors transfer to your elements
  • β™Ώ Accessibility transfer - Accessibility attributes preserved

πŸ› οΈ Development

# Install dependencies
pnpm i

# Watch and build
pnpm dev

# Production build
pnpm build

🀝 Contributing

We welcome contributions! Check out our Contributing Guidelines for detailed information on our development workflow, code standards, and how to submit changes.

πŸ“œ License

MIT

FAQs

Package last updated on 11 Jul 2025

Did you know?

Socket

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.

Install

Related posts

SocketSocket SOC 2 Logo

Product

About

Packages

Stay in touch

Get open source security insights delivered straight into your inbox.

  • Terms
  • Privacy
  • Security

Made with ⚑️ by Socket Inc

U.S. Patent No. 12,346,443 & 12,314,394. Other pending.