Skip to main content

Button Component

Figma

The glu-button component is a highly customizable button element that supports various appearances, sizes, and types. It functions either as a standard button or as a link when an href is provided.

Basic Usage

Example 1: Simple Button

Use the button as a clickable element.

Result
Loading...
Live Editor
<glu-button>Click Me</glu-button>

When an href is provided, the component renders as an anchor tag.

Result
Loading...
Live Editor
<glu-button href="https://example.com" target="_blank" rel="noopener noreferrer">
  Visit Example
</glu-button>

Different Appearances

Customize the visual style using the appearance property.

Result
Loading...
Live Editor
<div style={{ display: 'flex', gap: '1rem' }}>
  <glu-button>Filled</glu-button>
  <glu-button appearance="outline">Outline</glu-button>
  <glu-button appearance="ghost">Ghost</glu-button>
</div>

Button Sizes

Showcase the component in different sizes.

Result
Loading...
Live Editor
<div style={{ display: 'flex', gap: '1rem', alignItems: 'center' }}>
  <glu-button size="small">Small</glu-button>
  <glu-button size="medium">Medium</glu-button>
  <glu-button size="large">Large</glu-button>
</div>

Advanced Slot Usage

Customize the button content using slots for icons or additional text.

Result
Loading...
Live Editor
<div style={{ display: 'flex', gap: '1rem', alignItems: 'center' }}>
  <glu-button>
    <span slot="start">🔥</span>
    Submit
    <span slot="end">🚀</span>
  </glu-button>
</div>

Button in a Form

Use the button as a submission control within a form.

Result
Loading...
Live Editor
<form onsubmit="alert('Form submitted'); return false;">
  <glu-button type="submit">Submit Form</glu-button>
</form>

Properties

PropertyAttributeDescriptionTypeDefault
appearanceappearanceDetermines the visual style of the button"filled" | "ghost" | "outline"'filled'
buttonTypebutton-typeSpecifies the type of button."destructive" | "primary" | "secondary"'primary'
disableddisabledIf true, the user cannot interact with the button.anyundefined
hrefhrefContains a URL or a URL fragment that the hyperlink points to. If set, an anchor tag will be rendered.stringundefined
sizesizeDefines the size of the button."large" | "medium" | "small"'medium'

Slots

SlotDescription
Default content placed between the start and end slots.
"end"Content placed at the end of the button, after the default slot.
"icon-only"Content placed in the center of the button, typically used for icons.
"start"Content placed at the beginning of the button, before the default slot.

Dependencies

Used by

Graph


Built with StencilJS