Arco Design Mobile
repository·main·Indexed 19 days ago
https://github.com/arco-design/arco-design-mobileA comprehensive React UI component library optimized for mobile H5 and WebView environments. It features over 50 TypeScript-based components, including ActionSheet, Avatar, Badge, Button, Carousel, and Cell, with a focus on pixel-accurate design and high-quality finger interaction effects.
What's inside Arco Design Mobile
- Arco Design Mobile provides a set of built-in Icon components for use within your mobile applications. These icons can be customized via standard React props to control their styling and color behavior.
Use the Image component
mainThe
Imagecomponent is an enhanced version of the standard<img>tag. It supports various image fit modes (object-fit), loading indicators, and error handling. You can customize the loading state (loadingArea) and error state (errorArea) with custom React nodes.Key features include:
- Fit Modes: Supports standard CSS
object-fitvalues and special preview modes likepreview-xorpreview-y. - Loading/Error States: Automatically shows indicators or custom content when loading or when an error occurs.
- Retry Logic: Supports automatic retries via
retryTime. - Manual Control: Use
staticLabelto bypass the loading lifecycle and render a raw<img>tag, orshowImageto manually control loading.
- Fit Modes: Supports standard CSS
Use the CountDown component
mainThe
CountDowncomponent is used to display a countdown timer. It supports custom formatting, automatic starting, and millisecond rendering. You can control the timer via its props or by using the exposed ref methods to start, pause, or reset the countdown.<CountDown time={10000} format="HH:mm:ss" onFinish={() => console.log('Done!')} />Use the Skeleton component for loading states
mainThe
Skeletoncomponent displays placeholder graphics to indicate that content is currently loading. It supports various placeholder types including titles, paragraphs, avatars, and grids. You can customize the animation style, colors, and specific placeholder configurations.<Skeleton title={true} paragraph={true} avatar={true} animation="gradient" />Use the Slider component
mainTheSlidercomponent is a sliding input tool used for data entry. It displays the current value and an optional range. It supports both single value and range selection modes, horizontal and vertical orientations, and customizable tooltips and marks.Use the IndexBar component
mainThe
IndexBarcomponent is a navigation component used to quickly jump to specific sections of a list. It typically features a sticky header and a sidebar for rapid navigation.Key Features
- Sticky Headers: Automatically keeps the current group's title at the top while scrolling.
- Sidebar Navigation: A side indicator that allows users to jump to specific indices.
- Customizable Rendering: Extensive render props allow you to customize the sidebar, the sticky items, and the group items.
- Manual Control: Use the
scrollToIndexref method to programmatically scroll to a specific section.
Usage Modes
You can provide data to the
IndexBarin two ways:- Data-driven: Pass a
groupsarray containingIndexBarGroupItemobjects to thegroupsprop. - JSX-driven: Use
IndexBar.Groupas children. Note that when using JSX, certain props likeonGroupItemClickorrenderGroupItemmust be applied directly to theIndexBar.Groupcomponent rather than the parentIndexBar.
<IndexBar groups={[ { index: 'A', list: [{ content: 'Apple' }, { content: 'Apricot' }] }, { index: 'B', list: [{ content: 'Banana' }, { content: 'Blueberry' }] } ]} onChange={(index, trigger) => console.log(index, trigger)} />Use the Tabs component for navigation
mainTheTabscomponent is used to organize content into different panes, allowing users to switch between views by clicking on tab headers. It is a fundamental navigation component in the Arco Design Mobile library.Use the Sticky component for sticky layouts
mainTheStickycomponent provides a sticky layout effect where elements stick to the top, bottom, or both the window or a specified container. It is useful for creating headers, footers, or floating elements that follow the scroll position within a specific context.Use the Steps component to display progress
mainThe
Stepscomponent is used to display the progress of a task or to guide users through a complex process. It can be configured to run horizontally or vertically and supports custom icons, statuses, and alignment.Key Configuration Options
- Direction: Set
direction="horizontal"(default) ordirection="vertical". - Alignment: Use
align="center"oralign="start". Note that alignment defaults tocenterfor horizontal steps andstartfor vertical steps. - Current Step: Control the active step using the
currentprop (0-indexed). - Status: The overall progress state can be managed via
current, but individual steps can have their status overridden using thestatusprop onSteps.Step. - Data Source: You can provide steps via the
itemsprop (highest priority) or aschildren(lower priority).
Step Statuses
Available statuses for both the
Stepscomponent and individualStepelements are:finish: Completed step.error: Step with an error.wait: Pending step.process: Currently active step.
<Steps current={1}> <Steps.Step title="Step 1" description="Description 1" status="finish" /> <Steps.Step title="Step 2" description="Description 2" /> <Steps.Step title="Step 3" description="Description 3" /> </Steps>- Direction: Set
Use the DropdownMenu component
mainThe
DropdownMenuis a component that allows users to expand a dropdown box by clicking a selector to view and select from various options. It supports multiple selectors and can handle single or multiple selections.Key features include:
- Controlled/Uncontrolled modes: Use
selectIndexandvaluesfor controlled state, ordefaultSelectIndexanddefaultValuesfor uncontrolled state. - Multiple selection: Enable via the
multipleprop. - Cascading options: Supports hierarchical selection using
CascadeOptions. - Customization: Customize labels via
renderSelectLabeland handle interactions viaonOptionClickoronValuesChange.
<DropdownMenu options={options} onValuesChange={(values) => console.log(values)} />- Controlled/Uncontrolled modes: Use
Use Sticky Tabs for optimized tab and sticky combinations
mainTheSticky Tabscomponent provides a verified implementation for combining tabs with sticky behavior. It includes optimized logic to handle complex user experience requirements (such as scroll positioning and tab transitions) that are typically difficult to implement manually.Use the ImagePreview component
mainThe
ImagePreviewcomponent provides a full-screen image viewing experience with support for circular rotation, two-finger/double-tap zoom, and thumbnail zoom effects. It can be used as a component or via theopenmethod.Key features include:
- Gestures: Pinch-to-zoom, double-tap zoom, and swipe-to-close.
- Customization: Custom loading/error areas, custom indicators, and custom close buttons via
extraorrenderExtraprops. - Layout: Control image fit with
fit(preview-yorpreview-x) and spacing withspaceBetween.
// Example usage of ImagePreview component <ImagePreview images={[ { src: 'https://example.com/img1.png' }, { src: 'https://example.com/img2.png' } ]} openIndex={0} close={() => setVisible(false)} loop={true} />