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.

The shape of the button

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 filling

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.

Editing styles

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 variables

The demonstration focuses on visual tuning. The appearance changes via CSS variables or custom styles without the need to change the HTML structure.

When to use

Use wje-button when you want to solve a given UI problem consistently within the WebJET design system.

When not to use

Do not use a component outside of its responsibility; in an atypical case, prefer to assemble multiple smaller components.

Accessibility

Check keyboard controls, focus states, contrast and clear naming of interactive elements.

  • Prefer API component over manual DOM interventions.
  • Stick to design tokens and consistent naming conventions.
  • Before deployment, test the component in real data scenarios.

Attributes and properties

active

PopisUrčuje, či je komponent aktívny.
Atribútactive
Typboolean
Predvolenéfalse

caret

PopisUrčuje, či je voľba caret zapnutá a ovplyvňuje správanie komponentu.
Atribútcaret
Typboolean
Predvolenéfalse

color

PopisNastavuje farbu komponentu.
Atribútcolor
Typstring|string
Predvolenédefault

customEvent

PopisNastavuje textovú hodnotu uloženú vo voľbe custom-event.
Atribútcustom-event
Typstring
Predvolené-

dialog

PopisNastavuje textovú hodnotu uloženú vo voľbe dialog.
Atribútdialog
Typstring|object
Predvolené-

disabled

PopisVypína používateľskú interakciu s komponentom.
Atribútdisabled
Typboolean
Predvolenéfalse

fill

PopisNastavuje textovú hodnotu uloženú vo voľbe fill.
Atribútfill
Typstring
Predvolenésolid

href

PopisNastavuje cieľovú URL, keď komponent funguje ako odkaz.
Atribúthref
Typany
Predvolené-

outline

PopisUrčuje, či je voľba outline zapnutá a ovplyvňuje správanie komponentu.
Atribútoutline
Typboolean
Predvolenéfalse

round

PopisUrčuje, či je voľba round zapnutá a ovplyvňuje správanie komponentu.
Atribútround
Typboolean
Predvolenéfalse

stopPropagation

PopisUrčuje, či je voľba stop-propagation zapnutá a ovplyvňuje správanie komponentu.
Atribútstop-propagation
Typboolean
Predvolené-

toggle

PopisRiadi správanie voľby toggle v komponente.
Atribúttoggle
Typany
Predvolené-

tooltip

PopisUrčuje, či je voľba tooltip zapnutá a ovplyvňuje správanie komponentu.
Atribúttooltip
Typboolean
Predvolenéfalse

value

PopisNastavuje aktuálnu hodnotu komponentu.
Atribútvalue
Typany
Predvolené-

Events

NázovPopis
wje-button:clickVyvolá sa pri kliknutí na tlačidlo.
wje-button:toggleVyvolá sa pri prepnutí aktívneho stavu prepínacieho tlačidla.
wje-button:submitVyvolá sa pri spustení odoslania formulára tlačidlom.
wje-button:resetVyvolá sa pri spustení resetu formulára tlačidlom.

Methods

formAssociatedCallback

PopisSynchronizuje komponent so životným cyklom formulára pri zmene kontextu formulára.
Signatúra(form: HTMLFormElement) => void

formDisabledCallback

PopisAktualizuje stav deaktivácie komponentu pri zmene stavu nadradeného formulára.
Signatúra(disabled: boolean) => void

syncToggleState

PopisSynchronizuje toggle state s externým alebo interným zdrojom stavu.
Signatúra() => void

CSS shadow parts

NázovPopis
nativeŠtýluje koreňovú shadow časť komponentu.

CSS custom variables

NázovPopis
--wje-button-background-colorVlastná CSS premenná, ktorá riadi background color.
--wje-button-border-colorVlastná CSS premenná, ktorá riadi border color.
--wje-button-colorVlastná CSS premenná, ktorá riadi color.
--wje-button-border-radiusVlastná CSS premenná, ktorá riadi zaoblenie rohov.
--wje-button-border-widthVlastná CSS premenná, ktorá riadi border width.
--wje-button-border-styleVlastná CSS premenná na štýlovanie komponentu (border style).
--wje-button-border-colorVlastná CSS premenná, ktorá riadi border color.
--wje-button-margin-inlineVlastná CSS premenná, ktorá riadi margin inline.

Slots

NázovPopis
defaultPredvolený slot pre hlavný obsah komponentu.
iconSlot pre obsah ikony.
caretSlot pre obsah caret ikony.
startSlot pre obsah zobrazený pred hlavným obsahom.
endSlot pre obsah zobrazený za hlavným obsahom.
toggleSlot pre obsah prepínača.