WeChat applet WeUI.js web development style library


Overview

WeUI is a set of basic style libraries that are consistent with WeChat’s native visual experience. It is designed by the WeChat official design team for web development within WeChat, which can make users’ usage perception more unified. Using WeUI in WeChat web development has the following advantages:

  • The same visual effect as the WeChat client makes it easier for all WeChat users to use your website
  • Convenience Get quick use and reduce development and design costs
  • WeChat design team carefully builds it to be clear, concise and elegant

This style library currently includes button, cell, dialog, progress, toast, Various elements such as article and icon have been open sourced on GitHub. Visit http://weui.github.io/weui/ or scan the QR code on WeChat to preview.

Qrcode.png

Usage method

Installation

Method 1: Use bower to install

bower install --save weui

Method 2: Use npm to install

npm install --save weui

After choosing any method to install, you only need to introduce one of dist/style/weui.css or dist/style/weui.min.css into the page. . For example:

<!DOCTYPE html>
<html lang="en">
    <head>
        <meta charset="UTF-8">
        <meta name="viewport" content="width=device-width,initial-scale=1,user-scalable=0">
        <title>WeUI</title>
        <link rel="stylesheet" href="path/to/weui/dist/style/weui.min.css"/>
    </head>
    <body>
  
    </body>
</html>

Development

git clone https://github.com/weui/weui.git
cd weui
npm install -g gulp
npm install
gulp -ws

Run the gulp -ws command, which will monitor changes to all files in the src directory, and will start at 8080 by default Start the server on the port, and then open http://localhost:8080/example in the browser.


Element type

Button

Button can use a or button Label. To trigger the active state of a button on wap, the ontouchstart event must be triggered. You can add ontouchstart="" to global trigger on body. Common operation scenarios of

buttons: OK, Cancel, Warning, corresponding to classes: weui_btn_primary, weui_btn_default, weui_btn_warn, each scenario has It has its own gray state weui_btn_disabled. In addition, there is a hollow button weui_btn_plain_xxx. There are two types of button sizes in the client webview. The default width is 100%, and the width of small buttons is adaptive. , the distance between the borders on both sides and the text is 0.75em:

Button.png

<a href="#" class="weui_btn weui_btn_primary">按钮</a>
<a href="#" class="weui_btn weui_btn_disabled weui_btn_primary">按钮</a>
<a href="#" class="weui_btn weui_btn_warn">确认</a>
<a href="#" class="weui_btn weui_btn_disabled weui_btn_warn">确认</a>
<a href="#" class="weui_btn weui_btn_default">按钮</a>
<a href="#" class="weui_btn weui_btn_disabled weui_btn_default">按钮</a>
<div class="button_sp_area">
    <a href="#" class="weui_btn weui_btn_plain_default">按钮</a>
    <a href="#" class="weui_btn weui_btn_plain_primary">按钮</a>

    <a href="#" class="weui_btn weui_btn_mini weui_btn_primary">按钮</a>
    <a href="#" class="weui_btn weui_btn_mini weui_btn_default">按钮</a>
</div>

Cell

Cell, list view, use It is used to display information on the page in a list structure, which is the most commonly used content structure on WAP. Cell is composed of multiple sections, each section includes section header weui_cells_title and cells weui_cells.

Cell is composed of three parts: thumbnail weui_cell_hd, body weui_cell_bd, accessory weui_cell_ft, cell Use adaptive layout and add class weui_cell_primary to the parts that need to be adaptive:

Cell.png

List items with description

<div class="weui_cells_title">带说明的列表项</div>
<div class="weui_cells">
    <div class="weui_cell">
        <div class="weui_cell_bd weui_cell_primary">
            <p>标题文字</p>
        </div>
        <div class="weui_cell_ft">
            说明文字
        </div>
    </div>
</div>

Cell Various custom extensions can be made as needed, including auxiliary description, jump, and radio selection , check etc. The following is a list item with icons, descriptions, and jumps. In other cases, you can directly refer to the code under example:

<div class="weui_cells_title">带图标、说明、跳转的列表项</div>
<div class="weui_cells weui_cells_access">

    <a class="weui_cell" href="#">
        <div class="weui_cell_hd">
            <img src="" alt="icon" style="width:20px;margin-right:5px;display:block">
        </div>
        <div class="weui_cell_bd weui_cell_primary">
            <p>cell standard</p>
        </div>
        <div class="weui_cell_ft">
            说明文字
        </div>
    </a>
    <a class="weui_cell" href="#">
        <div class="weui_cell_hd">
            <img src="" alt="icon" style="width:20px;margin-right:5px;display:block">
        </div>
        <div class="weui_cell_bd weui_cell_primary">
            <p>cell standard</p>
        </div>
        <div class="weui_cell_ft">
            说明文字
        </div>
    </a>
</div>

Dialog

If If the system's alert form cannot meet the temporary view content requirements of the web page, you can customize a dialog similar to the alert form, and you can customize various controls in dialog , to meet the demand.

Dialog1.png

<div class="weui_dialog_confirm">
    <div class="weui_mask"></div>
    <div class="weui_dialog">
        <div class="weui_dialog_hd"><strong class="weui_dialog_title">弹窗标题</strong></div>
        <div class="weui_dialog_bd">自定义弹窗内容,居左对齐显示,告知需要确认的信息等</div>
        <div class="weui_dialog_ft">
            <a href="#" class="weui_btn_dialog default">取消</a>
            <a href="#" class="weui_btn_dialog primary">确定</a>
        </div>
    </div>
</div>

Dialog2.png

<div class="weui_dialog_alert">
    <div class="weui_mask"></div>
    <div class="weui_dialog">
        <div class="weui_dialog_hd"><strong class="weui_dialog_title">弹窗标题</strong></div>
        <div class="weui_dialog_bd">弹窗内容,告知当前页面信息等</div>
        <div class="weui_dialog_ft">
            <a href="#" class="weui_btn_dialog primary">确定</a>
        </div>
    </div>
</div>


##Progress

Progress is used in scenarios such as uploading and downloading that are time-consuming and need to display progress. The user can interrupt the operation at any time.

Progress.png

<div class="weui_progress">
    <div class="weui_progress_bar">
        <div class="weui_progress_inner_bar" style="width: 50%;"></div>
    </div>
    <a href="#" class="weui_progress_opr">
        <i class="weui_icon_cancel"></i>
    </a>
</div>


Toast

Toast is used to temporarily display a certain These messages will disappear automatically after a few seconds. This information is typically success, failure, or wait status information for lightweight operations.

Toast1.png

<div id="toast" style="display: none;">
    <div class="weui_mask_transparent"></div>
    <div class="weui_toast">
        <i class="weui_icon_toast"></i>
        <p class="weui_toast_content">已完成</p>
    </div>
</div>

Toast2.png

<div id="loadingToast" class="weui_loading_toast" style="display:none;">
    <div class="weui_mask_transparent"></div>
    <div class="weui_toast">
        <div class="weui_loading">
            <!-- :) -->
            <div class="weui_loading_leaf weui_loading_leaf_0"></div>
            <div class="weui_loading_leaf weui_loading_leaf_1"></div>
            <div class="weui_loading_leaf weui_loading_leaf_2"></div>
            <div class="weui_loading_leaf weui_loading_leaf_3"></div>
            <div class="weui_loading_leaf weui_loading_leaf_4"></div>
            <div class="weui_loading_leaf weui_loading_leaf_5"></div>
            <div class="weui_loading_leaf weui_loading_leaf_6"></div>
            <div class="weui_loading_leaf weui_loading_leaf_7"></div>
            <div class="weui_loading_leaf weui_loading_leaf_8"></div>
            <div class="weui_loading_leaf weui_loading_leaf_9"></div>
            <div class="weui_loading_leaf weui_loading_leaf_10"></div>
            <div class="weui_loading_leaf weui_loading_leaf_11"></div>
        </div>
        <p class="weui_toast_content">数据加载中</p>
    </div>
</div>


##Msg Page

Results Generally speaking, the page can be considered as a summary page at the end of the process after a series of operation steps. The main function of the result page is to inform the user of the operation processing results and necessary relevant details (which can be used to confirm whether the previous operation was incorrect); if the process is used to turn on or off some important functions, you can add the relevant information to the results page. Descriptive content related to functions; in addition, the results page can also carry some additional value operations, such as providing lottery draws, following public accounts and other functional entrances.

<div class="weui_msg">
    <div class="weui_icon_area"><i class="weui_icon_success weui_icon_msg"></i></div>
    <div class="weui_text_area">
        <h2 class="weui_msg_title">操作成功</h2>
        <p class="weui_msg_desc">内容详情,可根据实际需要安排</p>
    </div>
    <div class="weui_opr_area">
        <p class="weui_btn_area">
            <a href="#" class="weui_btn weui_btn_primary">确定</a>
            <a href="#" class="weui_btn weui_btn_default">取消</a>
        </p>
    </div>
    <div class="weui_extra_area">
        <a href="">查看详情</a>
    </div>
</div>
Result.png


Article

Text view displays large blocks of text, which are usually pages the main content on.

Article

Supports rich text styles such as segmentation, multi-layer titles, quotes, inline images, ordered/unordered lists, etc., and can respond to user selection operations. When using

Article

in the WeChat client webview, you must ensure that the text is sufficiently readable and legible, use standard fonts, ensure sufficient paragraph spacing, and no indentation at the beginning of the paragraph. .

<article class="weui_article">
    <h1>大标题</h1>
    <section>
        <h2 class="title">章标题</h2>
        <section>
            <h3>1.1 节标题</h3>
            <p>Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod
                tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam,
                quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo
                consequat. Duis aute</p>
        </section>
        <section>
            <h3>1.2 节标题</h3>
            <p>Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod
                tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam,
                cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non
                proident, sunt in culpa qui officia deserunt mollit anim id est laborum.</p>
        </section>
    </section>
</article>


ActionSheet

ActionSheet is used to display a series of interactive action collections, including instructions and jumps wait. Pops up from the bottom, generally used to respond to user clicks on the page.

ActionSheet.png

<div id="actionSheet_wrap">
    <div class="weui_mask_transition" id="mask"></div>
    <div class="weui_actionsheet" id="weui_actionsheet">
        <div class="weui_actionsheet_menu">
            <div class="weui_actionsheet_cell">示例菜单</div>
            <div class="weui_actionsheet_cell">示例菜单</div>
            <div class="weui_actionsheet_cell">示例菜单</div>
            <div class="weui_actionsheet_cell">示例菜单</div>
        </div>
        <div class="weui_actionsheet_action">
            <div class="weui_actionsheet_cell" id="actionsheet_cancel">取消</div>
        </div>
    </div>
</div>


Icon

icons.png

<i class="weui_icon_msg weui_icon_success"></i>
<i class="weui_icon_msg weui_icon_info"></i>
<i class="weui_icon_msg weui_icon_warn"></i>
<i class="weui_icon_msg weui_icon_waiting"></i>
<i class="weui_icon_safe weui_icon_safe_success"></i>
<i class="weui_icon_safe weui_icon_safe_warn"></i>
<div class="icon_sp_area">
    <i class="weui_icon_success"></i>
    <i class="weui_icon_success_circle"></i>
    <i class="weui_icon_success_no_circle"></i>
    <i class="weui_icon_info"></i>
    <i class="weui_icon_waiting"></i>
    <i class="weui_icon_waiting_circle"></i>
    <i class="weui_icon_circle"></i>
    <i class="weui_icon_warn"></i>
    <i class="weui_icon_download"></i>
    <i class="weui_icon_info_circle"></i>
    <i class="weui_icon_cancel"></i>
</div>


Technical Support and Feedback

Welcome to leave messages or feedback on GitHub.