EOS UI
Components

Button

A framework-agnostic Web Component button with semantic variants, CSS variable theming, and cross-framework integration.

Import

import '@eosjs/ui/button';

Introduction

Button is a framework-agnostic Web Component aligned with the EOS semantic color and sizing system. It works with React, Vue, Angular, and plain HTML without a framework adapter.

Basic Usage

Basic usage

ButtonActivated 0 times

Variants

Button supports semantic colors, visual variants, three sizes, loading, disabled, and icon-only states. The example groups these axes separately so each color and state can be compared without duplicating every combination.

Variants

PrimarySecondaryTertiaryOutlineGhost
Secondary colorSuccessWarningDangerSoft danger
SmallMediumLargeLoadingDisabled

API

Generated from custom-elements.json for eos-button.

Attributes

NameTypeDefaultDescription
aria-label———
aria-keyshortcuts———
aria-pressed———
color———
disabled———
full-width———
icon-only———
loading———
name———
size———
type———
value———
variant———

Attributes

AttributeTypeDefaultDescription
colordefault | primary | secondary | success | warning | dangerprimarySemantic color
variantsolid | bordered | light | flat | ghost | primary | secondary | tertiary | outline | danger | dangerSoftsolidVisual treatment
sizesm | md | lgmdButton size: 32/36/40px high
disabledbooleanfalsePrevent interaction
loadingbooleanfalseShow progress and prevent interaction
icon-onlybooleanfalseUse a square button at the selected size
full-widthbooleanfalseStretch the button to the host width
typebutton | submit | resetbuttonNative button type
aria-labelstring-Accessible name for icon-only buttons

Events

EventWhen it firesEvent object
clickThe button is activatedNative MouseEvent

Slots

Icons are passed through named slots; the component does not depend on a framework icon library:

<eos-button>
  <svg slot="start" viewBox="0 0 16 16" aria-hidden="true"><!-- icon --></svg>
  Save
  <svg slot="end" viewBox="0 0 16 16" aria-hidden="true"><!-- icon --></svg>
</eos-button>

<eos-button icon-only aria-label="Settings">
  <svg slot="start" viewBox="0 0 16 16" aria-hidden="true"><!-- icon --></svg>
</eos-button>

Framework integration

React

import { useEffect, useRef } from 'react';
import '@eosjs/ui';

export function MyButton() {
  const ref = useRef<HTMLElement>(null);

  useEffect(() => {
    const element = ref.current;
    const onClick = (event: Event) => {
      console.log('clicked:', event.type);
    };
    element?.addEventListener('click', onClick);
    return () => element?.removeEventListener('click', onClick);
  }, []);

  return <eos-button ref={ref}>Click me</eos-button>;
}

Vue 3

<template>
  <eos-button @click="handleClick">Click me</eos-button>
</template>

<script setup>
import '@eosjs/ui';

function handleClick(event) {
  console.log('clicked:', event.type);
}
</script>

Angular

import { Component, CUSTOM_ELEMENTS_SCHEMA } from '@angular/core';
import '@eosjs/ui';

@Component({
  selector: 'app-button',
  template: '<eos-button (click)="onClick($event)">Click me</eos-button>',
  schemas: [CUSTOM_ELEMENTS_SCHEMA],
})
export class ButtonComponent {
  onClick(event: MouseEvent) {
    console.log('clicked:', event.type);
  }
}

Native HTML

<script type="module">
  import '@eosjs/ui';
  document.querySelector('eos-button').addEventListener('click', (event) => {
    console.log('clicked:', event.type);
  });
</script>

<eos-button>Click me</eos-button>

CSS custom properties

The component consumes EOS semantic variables. Define them on the theme root or the eos-button host to provide Light/Dark values; the component keeps its implementation details inside Shadow DOM.

/* Define theme values centrally on :root or [data-theme]. */
:root {
  /* Figma semantic tokens: slash is represented by a hyphen in CSS. */
  --accent-accent: #006fee;
  --accent-accent-foreground: #fcfcfc;
  --accent-accent-hover: #3592f9;
  --default-default: #ebebec;
  --default-default-foreground: #18181b;
  --surface-surface-secondary: #efeff0;
  --border: #dedee0;
  --focus-ring: #006fee;
}

On this page