Skip to content

Component Library

Lyt.js provides a comprehensive component library with 38+ carefully designed components covering common UI needs.

Installation

bash
npm install @lytjs/components

Quick Start

Option 1: Register All Components

typescript
import { createApp } from '@lytjs/core'
import LytComponents from '@lytjs/components'

const app = createApp({
  template: `
    <div>
      <lyt-button type="primary">Click Me</lyt-button>
      <lyt-input v-model="value" placeholder="Enter text" />
    </div>
  `,
  state: { value: '' }
})

// Register all components at once
app.use(LytComponents)

app.mount('#app')

Option 2: Register Components On-Demand

typescript
import { createApp } from '@lytjs/core'
import { Button, Input, Avatar } from '@lytjs/components'

const app = createApp({
  // ...
})

// Register individual components
app.component('LytButton', Button)
app.component('LytInput', Input)
app.component('LytAvatar', Avatar)

app.mount('#app')

Component Overview

Base Components (5)

ComponentDescriptionImport Name
ButtonButton componentButton
IconIcon componentIcon
LinkLink componentLink
ContainerContainer componentContainer
DividerDivider componentDivider

Form Components (9)

ComponentDescriptionImport Name
InputText inputInput
CheckboxCheckboxCheckbox
RadioRadio buttonRadio
SelectDropdown selectorSelect
SwitchToggle switchSwitch
FormForm containerForm
DatePickerDate pickerDatePicker
TimePickerTime pickerTimePicker
CalendarCalendarCalendar

Feedback Components (4)

ComponentDescriptionImport Name
ModalModal dialogModal
ToastLightweight notificationToast
AlertAlert messageAlert
TooltipText tooltipTooltip
ComponentDescriptionImport Name
TabsTab navigationTabs
BreadcrumbBreadcrumb navigationBreadcrumb
PaginationPaginationPagination
CarouselImage carouselCarousel

Data Display Components (6)

ComponentDescriptionImport Name
TableData tableTable
TagTag / labelTag
BadgeStatus badgeBadge
SpinLoading spinnerSpin
EmptyEmpty stateEmpty
AvatarUser avatarAvatar

Extended Components (11)

ComponentDescriptionImport Name
DataTableAdvanced data tableDataTable
DialogDialog boxDialog
NotificationNotification messageNotification
PopoverPopover cardPopover
TabNavTab navigation barTabNav
CollapseCollapsible panelCollapse
DropdownDropdown menuDropdown
ProgressProgress barProgress
SliderRange sliderSlider
UploadFile uploadUpload
TreeTree controlTree

Component Examples

Button

vue
<template>
  <div>
    <!-- Basic usage -->
    <lyt-button>Default Button</lyt-button>

    <!-- Different types -->
    <lyt-button type="primary">Primary</lyt-button>
    <lyt-button type="success">Success</lyt-button>
    <lyt-button type="warning">Warning</lyt-button>
    <lyt-button type="danger">Danger</lyt-button>

    <!-- Different sizes -->
    <lyt-button size="small">Small</lyt-button>
    <lyt-button size="large">Large</lyt-button>

    <!-- Disabled state -->
    <lyt-button disabled>Disabled</lyt-button>

    <!-- Loading state -->
    <lyt-button loading>Loading...</lyt-button>

    <!-- Icon button -->
    <lyt-button icon="search">Search</lyt-button>
  </div>
</template>

Input

vue
<template>
  <div>
    <lyt-input v-model="value" placeholder="Enter text" />
    <lyt-input v-model="value" type="password" placeholder="Password" />
    <lyt-input v-model="value" type="number" placeholder="Number" />
    <lyt-input v-model="value" disabled placeholder="Disabled" />
    <lyt-input v-model="value" prefix="https://" suffix=".com" />
    <lyt-input v-model="value" prefix-icon="search" placeholder="Search" />
  </div>
</template>

Avatar

vue
<template>
  <div>
    <lyt-avatar>U</lyt-avatar>
    <lyt-avatar size="small">U</lyt-avatar>
    <lyt-avatar size="large">User</lyt-avatar>
    <lyt-avatar src="https://example.com/avatar.jpg" />
    <lyt-avatar shape="square">U</lyt-avatar>
    <lyt-avatar shape="circle">User</lyt-avatar>
  </div>
</template>

Table

vue
<template>
  <div>
    <lyt-table :columns="columns" :data="data" />
  </div>
</template>

<script>
export default {
  data() {
    return {
      columns: [
        { prop: 'name', label: 'Name' },
        { prop: 'age', label: 'Age' },
        { prop: 'address', label: 'Address' }
      ],
      data: [
        { name: 'John', age: 20, address: 'New York' },
        { name: 'Jane', age: 25, address: 'London' },
        { name: 'Bob', age: 30, address: 'Paris' }
      ]
    }
  }
}
</script>
vue
<template>
  <div>
    <lyt-button @click="visible = true">Open Modal</lyt-button>

    <lyt-modal
      v-model="visible"
      title="Confirm"
      @confirm="handleConfirm"
      @cancel="handleCancel"
    >
      <p>This is the modal content.</p>
    </lyt-modal>
  </div>
</template>

<script>
export default {
  data() {
    return { visible: false }
  },
  methods: {
    handleConfirm() { console.log('Confirmed') },
    handleCancel() { console.log('Cancelled') }
  }
}
</script>
vue
<template>
  <div>
    <lyt-carousel :autoplay="true" :interval="3000">
      <lyt-carousel-item>
        <div style="background: #99a9bf; text-align: center; line-height: 300px; color: #fff;">
          Slide 1
        </div>
      </lyt-carousel-item>
      <lyt-carousel-item>
        <div style="background: #d3dce6; text-align: center; line-height: 300px; color: #fff;">
          Slide 2
        </div>
      </lyt-carousel-item>
      <lyt-carousel-item>
        <div style="background: #99a9bf; text-align: center; line-height: 300px; color: #fff;">
          Slide 3
        </div>
      </lyt-carousel-item>
    </lyt-carousel>
  </div>
</template>

DatePicker

vue
<template>
  <div>
    <lyt-date-picker v-model="date" placeholder="Select date" />
  </div>
</template>

<script>
export default {
  data() { return { date: '' } }
}
</script>

TimePicker

vue
<template>
  <div>
    <lyt-time-picker v-model="time" placeholder="Select time" />
  </div>
</template>

<script>
export default {
  data() { return { time: '' } }
}
</script>

Calendar

vue
<template>
  <div>
    <lyt-calendar v-model="selectedDate" />
  </div>
</template>

<script>
export default {
  data() { return { selectedDate: new Date() } }
}
</script>

Theme System

Using ThemeProvider

vue
<template>
  <lyt-theme-provider :theme="theme">
    <div class="app">
      <!-- Your content -->
    </div>
  </lyt-theme-provider>
</template>

<script>
export default {
  data() {
    return {
      theme: 'light' // 'light' or 'dark'
    }
  }
}
</script>

Switching Themes Programmatically

typescript
import { useTheme } from '@lytjs/components'

// Get current theme
const currentTheme = useTheme()

// Switch theme
currentTheme.value = 'dark' // or 'light'

Custom Theme

typescript
import { ThemeProvider } from '@lytjs/components'

const customTheme = {
  colors: {
    primary: '#1890ff',
    success: '#52c41a',
    warning: '#faad14',
    danger: '#f5222d'
  }
}

CSS Variables

You can also customize the theme using CSS variables:

css
:root {
  --lyt-color-primary: #4f46e5;
  --lyt-color-success: #22c55e;
  --lyt-color-warning: #f59e0b;
  --lyt-color-danger: #ef4444;
  --lyt-color-text: #1f2937;
  --lyt-color-text-secondary: #6b7280;
  --lyt-color-border: #e5e7eb;
  --lyt-color-bg: #ffffff;
  --lyt-color-bg-secondary: #f9fafb;
  --lyt-border-radius: 6px;
  --lyt-font-size: 14px;
}

Component Status

The component library is fully production-ready with 38+ carefully designed components covering all common UI scenarios.

For more examples, see the examples/showcase-app directory, which includes detailed usage and example code for every component.

Released under the MIT License.