Skip to main content

Button

shadow

Buttons are a clickable element that allows you to display text, an icon, or both. Buttons can be easily customized using various attributes and CSS properties.

Basic usage

To use the Button component, include it in the HTML with the required attributes. Adding the disabled attribute makes the button inactive and unclickable.

Tooltip

The tooltip property allows you to display a text description of the button when the mouse is moved over it. To display the text, you need to add a tooltip attribute to the button with the text content. By adding the tooltip-placement attribute it is possible to specify the position of the text display.

Toggle

The toggle property allows you to assign two different states to a button and toggle between them with a click. Setting the value assigns a default state to the button.
To set the available states, you need to add two child elements to the button with a toggle value slot and also with a state property, which determines the actual state value of the button.

Caret

The caret property allows you to display an arrow on the button. To display the arrow, you need to add the caret attribute to the button.

Button Shape

The round property allows you to adjust the shape of the button. By default, the buttons are rectangular with slightly rounded edges. Adding this attribute will increase the roundness of the button.

Form button

The submit and reset properties allow you to use the button to submit or reset the form. A button with the submit property sends the form that is linked to it. A button with the reset property will reset all form values.

Button Fill

The Fill property specifies the background and border fill of the button. By default, the buttons have a solid background. Other options are link and outline.

Button size

The size property specifies the size of the button. Setting this property will change the internal offset of the button.

Button icons

Icons can also be displayed in buttons by inserting the wje-icon element. You modify their location within the button using the slot attribute and the start or end property. If the button contains no text and consists of an icon only, use the icon-only property.

For more information about icons, see Icons.

Styling

Button colors

The color property adjusts the background and border color of the button. Setting this value will change the button color to one of the colors in the preset color palette. By default, the buttons have a primary background.

Button edge color

The color property can be combined with the fill property.

CSS Custom Properties

When to use

Use wje-button when you need a consistent WebJET-based implementation for this UI concern.

When not to use

Do not stretch the component beyond its responsibility; compose smaller primitives for edge cases.

Accessibility

Validate keyboard behavior, focus states, contrast, and meaningful labels for interactive elements.

Best Practices

  • Prefer component APIs over direct DOM manipulation.
  • Stick to design tokens and naming conventions.
  • Test components with realistic data before production rollout.

Attributes and Properties

disabled

DescriptionGet disabled state of the Button element.
Attributedisabled
Typeboolean
Default-

color

DescriptionGet color of the Button element.
Attributecolor
Typestring|string
Default-

value

DescriptionSets the current value of the component.
Attributevalue
Typeany
Default-

active

DescriptionGet active state of the Button element.
Attributeactive
Typeboolean
Default-

href

DescriptionSets the target URL used when the component acts as a link.
Attributehref
Typeany
Default-

Events

NameDescription
wje-button:clickEmitted when the button is clicked.
wje-button:toggleEmitted when a toggle-style button changes its active state.
wje-button:submitEmitted when the button triggers form submission behavior.
wje-button:resetEmitted when the button triggers form reset behavior.

Methods

formAssociatedCallback

DescriptionSynchronizes the component with the form-associated custom element lifecycle when form context changes.
Signature(form: HTMLFormElement) => void

formDisabledCallback

DescriptionUpdates component disabled state when the owning form switches between enabled and disabled modes.
Signature(disabled: boolean) => void

CSS Shadow Parts

NameDescription
nativeThe component's native wrapper.

CSS Custom Properties

NameDescription
--wje-button-background-colorBackground color of the component;.
--wje-button-border-colorBorder color of the component;.
--wje-button-colorColor of the component;.
--wje-button-border-radiusBorder radius of the component;.
--wje-button-border-widthBorder width of the component;.
--wje-button-border-styleBorder style of the component;.
--wje-button-border-colorBorder color of the component;.
--wje-button-margin-inlineMargin inline of the component;.

Slots

NameDescription
defaultDefault slot for the main component content.
iconSlot for icon content.
caretSlot for caret icon content.
startSlot for content shown before the main content.
endSlot for content shown after the main content.
toggleSlot for toggle control content.