Bifrost UI (BUI)

repository·main·Indexed 41 days ago

https://github.com/alibaba/bifrostui

A React-based cross-platform component library designed to bridge Web development and Mini-program development (such as Alipay and WeChat) using a single codebase. It includes core packages like @bifrostui/react, @bifrostui/styles, @bifrostui/types, and @bifrostui/utils, and requires webpack 5.x or higher.

Tokens
226.9K
Snippets
600
Records
833
Agent score
47%

What's inside Bifrost UI

  1. Overview of Bifrost UI (BUI)

    main

    Bifrost UI (BUI) is a cross-platform component library designed to bridge the gap between H5 (Web) and Mini-programs. It provides a unified solution for cross-platform development, allowing developers to use the same components across different environments.

    Key Features

    • Multi-platform Adaptation: Universal components compatible with both Web and Mini-programs.
    • TypeScript Support: Developed with TypeScript for static type checking and improved developer experience.
    • Customizable Themes: Supports theme customization to match your brand.
    • On-demand Loading: Supports tree-shaking/on-demand imports to keep bundle sizes small.
    • High Quality Components: Includes 40+ high-quality, mobile-first components.
    • Flexible Composition: Components are designed to be encapsulated flexibly for various usage scenarios.
    • Stability: High unit test coverage (>90%).
  2. Use Toast for lightweight notifications

    main

    The Toast component provides lightweight, semi-transparent black notifications used for displaying operation results or status updates. It supports several predefined types: Toast, Toast.warning, Toast.loading, Toast.success, and Toast.fail.

    Important Recommendation: Use the Hooks-based approach (Toast.useToast) instead of static methods. Static methods cannot access the component context, meaning ThemeProvider data will not be applied to them. Using Toast.useToast allows you to create a contextHolder that respects your application's theme and context.

  3. Use the Tabs component for tab switching

    main

    The Tabs component is used for switching between different content views. It works in conjunction with Tab (for defining individual tabs) and TabPanel (for defining the content associated with each tab).

    Platform Differences

    • Mini-program vs H5:
      • In Mini-programs, the bottom line of the active tab uses a gradient animation, whereas H5 uses a movement animation.
      • In Mini-programs, if tabs exceed the scrollable width, clicking a tab will not automatically center it in the view.