@cleartrip/ct-design-components

中文文档
5.32.0发布于 2026/11/16ISCTypeScriptESM + CJS近 30 天下载 1.9万

Core components collection for Cleartrip Design System with cross-platform React and React Native support

原始使用文档
文档目录19 节
  1. Overview
  2. Installation
  3. Components
  4. Container
  5. API Reference
  6. Container Props
  7. Container Ref Methods
  8. Related Packages
  9. Core Components
  10. Form Components
  11. Navigation
  12. Feedback
  13. Data Display
  14. Browser Support
  15. Module Formats
  16. Development
  17. Contributing
  18. License
  19. Changelog

@cleartrip/ct-design-components

Core components collection for Cleartrip Design System

Version License: ISC

Overview

@cleartrip/ct-design-components is a foundational package in the Cleartrip Design System that provides essential UI components with cross-platform support for React and React Native applications. This package focuses on core layout and container components with advanced features like haptic feedback support.

Installation

# npm
npm install @cleartrip/ct-design-components

# yarn  
yarn add @cleartrip/ct-design-components

# pnpm
pnpm add @cleartrip/ct-design-components

Components

Container

A versatile container component that serves as a foundational layout element with support for haptic feedback, event handling, and flexible styling.

Features

  • Cross-platform: Works seamlessly on React and React Native
  • Haptic Feedback: Built-in haptic feedback support with customizable intensity
  • Flexible Rendering: Supports multiple HTML semantic elements (main, section, article, div, p)
  • Event Handling: Mouse events, click handlers, and layout change callbacks
  • Accessibility: Focus management and measurement capabilities
  • Styling: Custom style configuration with design system integration

Basic Usage

import { Container } from '@cleartrip/ct-design-components';

function App() {
  return (
    <Container
      as="main"
      onClick={(event) => console.log('Container clicked')}
      styleConfig={{
        root: [{ padding: '16px', backgroundColor: '#f5f5f5' }]
      }}
    >
      <h1>Welcome to Cleartrip</h1>
      <p>Your content goes here...</p>
    </Container>
  );
}

Haptic Feedback

<Container
  hapticEnabled={true}
  hapticVariant="subtle"
  hapticRepeat={false}
  onClick={() => console.log('Haptic feedback triggered')}
>
  Interactive content with haptic feedback
</Container>

Advanced Usage with Ref

import { Container, ContainerRef } from '@cleartrip/ct-design-components';
import { useRef } from 'react';

function MyComponent() {
  const containerRef = useRef<ContainerRef>(null);

  const handleFocus = () => {
    containerRef.current?.focus();
  };

  const measureContainer = () => {
    containerRef.current?.measure((x, y, width, height, pageX, pageY) => {
      console.log('Container dimensions:', { x, y, width, height, pageX, pageY });
    });
  };

  return (
    <Container
      ref={containerRef}
      onLayout={(event) => console.log('Layout changed:', event.layout)}
      onMouseEnter={() => console.log('Mouse entered')}
      onMouseLeave={() => console.log('Mouse left')}
    >
      Content with measurement and event handling
    </Container>
  );
}

API Reference

Container Props

PropTypeDefaultDescription
idstring-HTML id attribute
childrenReact.ReactNode-Child elements to render
as'main' | 'section' | 'article' | 'div' | 'p''div'HTML element type to render
showScrollIndicatorboolean-Show scroll indicator (React Native)
onClick(event: unknown) => void-Click event handler
onLayout(event: LayoutEvent) => void-Layout change handler (React Native)
onMouseEnterMouseEventHandler<HTMLElement>-Mouse enter handler
onMouseLeaveMouseEventHandler<HTMLElement>-Mouse leave handler
onTransitionEnd() => void-Transition end handler
styleConfig{ root?: Styles[] }-Custom style configuration
hapticEnabledbooleanfalseEnable haptic feedback
hapticVariant'subtle' | 'loud''subtle'Haptic feedback intensity
hapticRepeatbooleanfalseRepeat haptic feedback

Container Ref Methods

MethodDescription
focus()Focus the container element
getBoundingRectWithCallback(callback?)Get bounding rectangle with callback
measure(callback)Measure container dimensions and position
getElementRef()Get the underlying element reference

The Cleartrip Design System includes 60+ specialized component packages:

Core Components

  • @cleartrip/ct-design-button - Button components
  • @cleartrip/ct-design-typography - Text and typography
  • @cleartrip/ct-design-card - Card layouts
  • @cleartrip/ct-design-box - Layout containers

Form Components

  • @cleartrip/ct-design-field - Form fields
  • @cleartrip/ct-design-checkbox - Checkboxes
  • @cleartrip/ct-design-radio - Radio buttons
  • @cleartrip/ct-design-dropdown - Dropdown menus

Navigation

  • @cleartrip/ct-design-nav-tabs - Navigation tabs
  • @cleartrip/ct-design-breadcrumb - Breadcrumb navigation

Feedback

  • @cleartrip/ct-design-toast - Toast notifications
  • @cleartrip/ct-design-modal - Modal dialogs
  • @cleartrip/ct-design-tooltip - Tooltips
  • @cleartrip/ct-design-spinner - Loading indicators

Data Display

  • @cleartrip/ct-design-accordion - Collapsible content
  • @cleartrip/ct-design-carousel - Content carousels
  • @cleartrip/ct-design-rating - Star ratings
  • @cleartrip/ct-design-badge - Status badges

See complete component list

Browser Support

  • React: 16.8.0 or higher
  • React DOM: 16.8.0 or higher
  • React Native: 0.68.0 or higher (optional peer dependency)

Module Formats

This package supports multiple module formats:

  • ES Modules: dist/ct-design-components.esm.js
  • CommonJS: dist/ct-design-components.cjs.js
  • Browser: Optimized browser builds available
  • TypeScript: Full TypeScript definitions included

Development

# Build the package
pnpm build-package

# Watch for changes during development
pnpm watch-package

# Clean build
pnpm build-package:clean

Contributing

This package is part of the Cleartrip Design System. For contribution guidelines, please refer to the main repository documentation.

License

ISC

Changelog

See CHANGELOG.md for version history and updates.


Cleartrip Design System | Documentation | Component Library | GitHub

版本与发布记录

@cleartrip/ct-design-components 共发布 1,210 个版本,首次发布于 2023/10/25;过去 12 个月发布了 667 个版本。

版本发布日期距今
5.32.0latest2026/11/16今天
5.32.0-SNAPSHOT-5.32.0-SNAPSHOT-bs-height-check-161120161537.02026/11/16今天
5.32.0-SNAPSHOT-bs-height-check-151120162243.02026/11/16今天
3.28.0-SNAPSHOT-hdp-revamp-v3.02026/11/124 天前
3.28.0-SNAPSHOT-hdp-revamp-v2.02026/11/124 天前
5.32.0-SNAPSHOT-biztrip-rn-sme-snapshot-11-11-26.02026/11/115 天前

其他发布通道:SNAPSHOT-CAROUSEL → 2.2.0-SNAPSHOT-CAROUSEL.0,SNAPSHOT-ITINERARY-OTP-CAROUSEL → 2.2.0-SNAPSHOT-ITINERARY-OTP-CAROUSEL.2,SNAPSHOT-ITINERARY → 2.2.0-SNAPSHOT-ITINERARY.2,SNAPSHOT-ITINERARY-OUTSIDECLICK → 2.2.0-SNAPSHOT-ITINERARY-OUTSIDECLICK.2,SNAPSHOT-SPINNER → 2.1.1-SNAPSHOT-SPINNER.0,SNAPSHOT-DRAWERV2 → 2.3.0-SNAPSHOT-DRAWERV2.0。

关于 @cleartrip/ct-design-components 的常见问题

@cleartrip/ct-design-components 是什么?

Core components collection for Cleartrip Design System with cross-platform React and React Native support

如何安装 @cleartrip/ct-design-components?

在项目目录运行 npm install @cleartrip/ct-design-components,或使用 pnpm add / yarn add / bun add。它还需要宿主项目提供 peer 依赖:react(>=16.8.0)、react-dom(>=16.8.0)。npm 7 及以上与 pnpm 8 及以上默认会自动安装必需的 peer 依赖,Yarn 需要手动安装。

@cleartrip/ct-design-components 支持 TypeScript 吗?

支持。包内自带 TypeScript 类型声明(package.json 声明了 types 入口),安装后即可获得类型提示,无需再安装 @types 包。

@cleartrip/ct-design-components 支持 ESM 还是 CommonJS?

同时提供 ES Module 与 CommonJS 入口,import 和 require() 都可以使用,打包工具会自动选择合适的版本。

@cleartrip/ct-design-components 可以商用吗?

@cleartrip/ct-design-components 使用 ISC 许可。宽松许可:允许商业使用、修改和再分发,通常只需在分发时保留原版权与许可声明。以上为概括,不构成法律意见,请以许可原文为准。

@cleartrip/ct-design-components 的下载量有多少?

根据 npm 官方下载统计,@cleartrip/ct-design-components 在 2026/10/10 – 2026/11/08 这 30 天内被下载 19,119 次,日均约 637 次。下载量会把 CI 构建、镜像同步和作为其他包依赖的安装一并计入,适合横向比较热度,不能直接等同于使用人数。

@cleartrip/ct-design-components 还在维护吗?

最新版本 5.32.0 发布于 2026/11/16(今天);至今共发布 1210 个版本,其中过去 12 个月发布了 667 个;首次发布于 2023/10/25。发布频率只是参考信号:功能稳定的工具可能很少需要更新,建议结合源码仓库的 issue 和提交记录判断。