Element UI

repository·dev·Indexed 11 days ago

https://github.com/elemefe/element

A comprehensive UI toolkit and component library for Vue.js 2.0 web development. Version 2.15.14 provides a set of professional interface components, including the chalk theme (element-theme-chalk) and specialized packages like element-steps. It supports modern browsers and IE10+, and includes Web Types for improved IDE assistance in JetBrains tools.

Tokens
184.6K
Snippets
738
Records
904
Agent score
97%

What's inside Element UI

  1. Use the Result component for operation feedback

    dev

    The el-result component is used to provide feedback to users regarding the outcome of an operation or to display access exceptions (e.g., 404 errors, success messages, or warnings).

    <el-result icon="success" title="Success Tip" subTitle="Please follow the instructions">
      <template slot="extra">
        <el-button type="primary" size="medium">Back</el-button>
      </template>
    </el-result>
  2. Configure leaf nodes in lazy mode

    dev

    In lazy mode, the tree cannot predict if a node is a leaf until data is loaded. You can use the isLeaf key in the props configuration to explicitly tell the tree which property in your data indicates a leaf node, preventing the display of an expand icon on leaf nodes.

    <el-tree
      :props="props"
      :load="loadNode"
      lazy
      show-checkbox>
    </el-tree>
    
    <script>
      export default {
        data() {
          return {
            props: {
              label: 'name',
              children: 'zones',
              isLeaf: 'leaf' // The key in your data that indicates if it's a leaf
            },
          };
        },
        // ... loadNode implementation
      };
    </script>
  3. Configure global component size in Element UI

    dev

    In version 2.15.4, you can configure a global size field when introducing Element. This setting changes the default size for all components across your application. Additionally, many components like Button, Form, FormItem, Tag, Radio, Checkbox, ColorPicker, and Table support a size prop which accepts medium, small, and mini.

    // Example concept: configuring size globally during initialization
    // Note: Actual implementation depends on your build/import setup
    const element = {
      size: 'small'
    };
  4. Customize the skeleton layout with the template slot

    dev

    When the default row-based skeleton is insufficient, use the template slot to define a custom structure. Inside this slot, use el-skeleton-item to represent different types of content (images, headings, text, etc.).

    Best Practice: Structure your custom template to match the real DOM as closely as possible in terms of height and layout to avoid 'DOM bouncing' (sudden layout shifts) when the loading state ends.

    <template>
      <el-skeleton style="width: 240px">
        <template slot="template">
          <el-skeleton-item variant="image" style="width: 240px; height: 240px;" />
          <div style="padding: 14px;">
            <el-skeleton-item variant="p" style="width: 50%" />
            <div style="display: flex; align-items: center; justify-items: space-between;">
              <el-skeleton-item variant="text" style="margin-right: 16px;" />
              <el-skeleton-item variant="text" style="width: 30%;" />
            </div>
          </div>
        </template>
      </el-skeleton>
    </template>
  5. Configure InputNumber steps and precision

    dev

    You can control how the value increments and how many decimal places are allowed:

    • Steps: Use the step attribute to define the increment amount.
    • Step Strictly: Set step-strictly to true to ensure the input value is always a multiple of the step value.
    • Precision: Use the precision attribute to set the number of decimal places.

    Note: precision must be a non-negative integer and should not be less than the decimal places used in the step value.

    <template>
      <!-- Step strictly example -->
      <el-input-number v-model="num" :step="2" step-strictly></el-input-number>
    
      <!-- Precision example -->
      <el-input-number v-model="num" :precision="2" :step="0.1" :max="10"></el-input-number>
    </template>
  6. Understand Element's color palette categories

    dev

    Element UI uses a structured color system to ensure visual consistency. The palette is divided into three main categories:

    1. Main Color: The primary brand color (default is a bright blue #409EFF).
    2. Secondary Colors: Scene-specific colors used to indicate different states or levels of importance:
      • success: Positive actions/states (#67C23A)
      • warning: Cautionary states (#E6A23C)
      • danger: Destructive or error states (#F56C6C)
      • info: Informational states (#909399)
    3. Neutral Colors: Used for text, backgrounds, and borders to establish hierarchy:
      • Text: textPrimary, textRegular, textSecondary, textPlaceholder.
      • Borders: borderBase, borderLight, borderLighter, borderExtraLight.
      • Basics: white, black, and transparent.