Getting Started

Usage

Learn how to use EletroDS Vue 3 components in your application.

Learn how to use EletroDS Vue 3 components in your application.

Basic Usage

After installation, you can start using the components in your Vue templates:

App.vue
<template>
  <div>
    <MeButton color="primary">Click me</MeButton>
  </div>
</template>

<script setup>
import { MeButton } from '@mercadoeletronico/eds-next'
</script>

Component Registration

Global Registration

Register components globally for use throughout your application:

main.ts
import { createApp } from 'vue'
import { MeButton } from '@mercadoeletronico/eds-next'

const app = createApp(App)

app.component('MeButton', MeButton)

Local Registration

Register components locally in specific components:

MyComponent.vue
<script setup>
import { MeButton } from '@mercadoeletronico/eds-next'
</script>

<template>
  <MeButton color="primary">Local Button</MeButton>
</template>

TypeScript Support

The library provides full TypeScript support with proper type definitions:

TypedButton.vue
<script setup lang="ts">
import { MeButton, type ButtonProps } from '@mercadoeletronico/eds-next'

const buttonProps: ButtonProps = {
  color: 'primary',
  size: 'md',
  disabled: false
}
</script>

<template>
  <MeButton v-bind="buttonProps">Typed Button</MeButton>
</template>

Event Handling

Handle component events using Vue's event system:

EventHandling.vue
<template>
  <MeButton @click="handleClick">Click me</MeButton>
</template>

<script setup lang="ts">
const handleClick = (event: MouseEvent) => {
  console.log('Button clicked!', event)
}
</script>

Styling and Customization

Components use Tailwind CSS classes and can be customized using the class prop:

CustomButton.vue
<template>
  <MeButton class="font-bold rounded-full">
    Custom Button
  </MeButton>
</template>

You can also use the ui prop to override specific slots:

UiPropButton.vue
<template>
  <MeButton :ui="{ base: 'shadow-lg' }">
    Styled Button
  </MeButton>
</template>

Best Practices

  1. Use TypeScript: Take advantage of the built-in type definitions
  2. Component Names: Use consistent naming conventions (e.g., MeButton)
  3. Props Validation: Leverage TypeScript for prop validation
  4. Event Handling: Use proper event typing for better development experience

Color System

EletroDS uses a semantic color system:

ColorUsage
primaryPrimary brand actions
secondarySecondary actions
successSuccess states and confirmations
warningWarning states
errorError states and destructive actions
infoInformational elements
neutralNeutral elements

Size System

Components support consistent sizing:

SizeDescription
xsExtra small
smSmall
mdMedium (default)
lgLarge
xlExtra large

Next Steps

Components

Explore all available components and their documentation.

Button

Learn about the Button component in detail.