Element UI is a comprehensive Vue.js 2.0 component library that provides 90 high-quality UI components for building modern web applications. It offers complete form controls, layout systems, navigation components, data display elements, and feedback mechanisms with consistent design language, extensive customization, internationalization support, and comprehensive accessibility features.
npm install element-uiGlobal installation (recommended):
import Vue from 'vue';
import ElementUI from 'element-ui';
import 'element-ui/lib/theme-chalk/index.css';
Vue.use(ElementUI);On-demand imports:
import { Button, Input, Message } from 'element-ui';
import 'element-ui/lib/theme-chalk/button.css';
import 'element-ui/lib/theme-chalk/input.css';
Vue.component('el-button', Button);
Vue.component('el-input', Input);
Vue.prototype.$message = Message;import Vue from 'vue';
import ElementUI from 'element-ui';
import 'element-ui/lib/theme-chalk/index.css';
Vue.use(ElementUI, {
size: 'medium', // set default component size
zIndex: 3000, // set default z-index for popups
locale: {} // set locale configuration
});
// Use components in templates
// <el-button type="primary" @click="handleClick">Click Me</el-button>
// <el-input v-model="value" placeholder="Enter text"></el-input>
// Use global services
this.$message.success('Operation completed');
this.$confirm('Delete this item?', 'Warning').then(() => {
// User confirmed
});Element UI is built around several key architectural patterns:
Complete set of form input components including text inputs, selections, date pickers, and validation. Provides controlled and uncontrolled patterns with built-in validation support.
// Core form components
const Button = Vue.component;
const Input = Vue.component;
const Select = Vue.component;
const DatePicker = Vue.component;
const Form = Vue.component;
// Form validation
const FormItem = Vue.component;
// Configuration for global installation
interface ElementUIOptions {
size?: 'large' | 'medium' | 'small' | 'mini';
zIndex?: number;
locale?: any;
i18n?: (path: string, options?: any) => string;
}
function install(Vue: typeof Vue, options?: ElementUIOptions): void;Flexible layout components for creating responsive grid systems and application layouts with containers, rows, columns, and semantic layout elements.
const Row = Vue.component;
const Col = Vue.component;
const Container = Vue.component;
const Header = Vue.component;
const Main = Vue.component;
const Aside = Vue.component;
const Footer = Vue.component;Navigation elements including menus, breadcrumbs, tabs, and pagination for building intuitive user interfaces with clear information hierarchy.
const Menu = Vue.component;
const Tabs = Vue.component;
const Breadcrumb = Vue.component;
const Pagination = Vue.component;
const Dropdown = Vue.component;Components for presenting and organizing data including tables, trees, tags, cards, and specialized display elements for rich content presentation.
const Table = Vue.component;
const Tree = Vue.component;
const Card = Vue.component;
const Tag = Vue.component;
const Timeline = Vue.component;
const Descriptions = Vue.component;User feedback mechanisms including alerts, messages, notifications, loading states, and confirmation dialogs for interactive communication.
// Global services available on Vue prototype
interface VuePrototype {
$message: MessageService;
$notify: NotificationService;
$msgbox: MessageBoxService;
$alert: (message: string, title?: string, options?: any) => Promise<void>;
$confirm: (message: string, title?: string, options?: any) => Promise<void>;
$prompt: (message: string, title?: string, options?: any) => Promise<any>;
$loading: LoadingService;
}
const Dialog = Vue.component;
const Alert = Vue.component;
const Popover = Vue.component;
const Tooltip = Vue.component;System-level services for loading states, messages, notifications, and modal dialogs that can be accessed programmatically throughout the application.
interface MessageService {
(message: string): void;
success(message: string): void;
warning(message: string): void;
info(message: string): void;
error(message: string): void;
}
interface LoadingService {
(options?: LoadingOptions): LoadingInstance;
service(options?: LoadingOptions): LoadingInstance;
directive: Vue.DirectiveOptions;
}
interface NotificationService {
(options: NotificationOptions): NotificationInstance;
success(message: string, title?: string): NotificationInstance;
warning(message: string, title?: string): NotificationInstance;
info(message: string, title?: string): NotificationInstance;
error(message: string, title?: string): NotificationInstance;
}Built-in internationalization system supporting multiple languages with customizable locale configurations and integration with vue-i18n.
interface LocaleSystem {
use(lang: any): void;
t(path: string, options?: any): string;
i18n(handler: (path: string, options?: any) => string): void;
}
const locale: LocaleSystem;Additional utility components for enhanced functionality and transitions.
/**
* Collapse transition component for smooth expand/collapse animations
*/
const CollapseTransition = Vue.component;
/**
* Custom scrollbar component
*/
const Scrollbar = Vue.component;
/**
* Infinite scroll directive for auto-loading content
*/
const InfiniteScroll = Vue.directive;// Component size variations
type ComponentSize = 'large' | 'medium' | 'small' | 'mini';
// Horizontal alignment options
type HorizontalAlignment = 'left' | 'center' | 'right';
// Base component interface
interface ElementUIComponent extends Vue {
$el: HTMLElement;
}
// Installation options
interface InstallationOptions {
locale?: any;
i18n?: (path: string, options?: any) => string;
size?: ComponentSize;
}