Skip to main content

Toggle

shadow

Toggle elements are small interactive controls that allow you to switch between two states. You can activate them with a click of the mouse. They are most often used to activate and deactivate functionalities or to switch between showing and hiding other elements.

Basic Usage​

The sample shows the toggle in its simplest form, i.e. as a toggle with default appearance and behavior.

Colors​

The demonstration compares the color variations of the toggle component to see how they affect the meaning and readability of the state.

Custom CSS variables​

Using CSS variables you can adjust the dimensions, radius and colors of the track and handle without the need for a custom wrapper component.

When to use​

Use wje-toggle when the user enters a value, selects options, or performs an action on a form.

When not to use​

Don't just use it as a visual decorative element without interaction. In this case, give priority to the presentation components.

Accessibility​

Always link the component to the description (label/aria-label), keep keyboard control, and display a clear message on validation errors.

  • Keep validation rules and error states consistent across the entire form.
  • For asynchronous operations, display the load status or disabled status.
  • For complex forms, prefer smaller sections and immediate feedback.

Attributes and properties​

checked​

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

customErrorDisplay​

PopisRiadi validáciu alebo stavové hlášky pre voľbu custom-error-display.
Atribútcustom-error-display
Typboolean
Predvolenéfalse

disabled​

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

required​

PopisOznačí komponent ako povinný pre validáciu formulára.
Atribútrequired
Typboolean
Predvolené-

validateOnChange​

PopisUrčuje, či je voľba validate-on-change zapnutá a ovplyvňuje správanie komponentu.
Atribútvalidate-on-change
Typboolean
Predvolenéfalse

value​

PopisNastavuje aktuálnu hodnotu komponentu.
Atribútvalue
Typstring
Predvolenéon

Events​

NázovPopis
wje-toggle:inputVyvolá sa pri zmene vstupnej hodnoty.
wje-toggle:changeVyvolá sa pri zmene hodnoty komponentu.

Methods​

Pre tento komponent nie sú dostupné žiadne verejné metódy.

CSS shadow parts​

NázovPopis
nativeŠtýluje koreňovú shadow časť komponentu.
inputŠtýluje shadow časť input.
toggleŠtýluje toggle slot a oblasť markera.

CSS custom variables​

NázovPopis
--wje-toggle-color-baseVlastná CSS premenná, ktorá riadi color base.
--wje-toggle-widthVlastná CSS premenná, ktorá riadi width.
--wje-toggle-heightVlastná CSS premenná, ktorá riadi height.
--wje-toggle-border-radiusVlastná CSS premenná, ktorá riadi zaoblenie rohov.
--wje-toggle-handle-widthVlastná CSS premenná, ktorá riadi handle width.
--wje-toggle-handle-heightVlastná CSS premenná, ktorá riadi handle height.
--wje-toggle-handle-border-radiusVlastná CSS premenná, ktorá riadi zaoblenie rohov.
--wje-toggle-handle-colorVlastná CSS premenná, ktorá riadi handle color.
--wje-toggle-handle-shadowVlastná CSS premenná, ktorá riadi tieň.
--wje-toggle-handle-shadow-checkedVlastná CSS premenná, ktorá riadi tieň.
--wje-toggle-durationVlastná CSS premenná na štýlovanie komponentu (duration).
--wje-toggle-curveVlastná CSS premenná na štýlovanie komponentu (curve).

Slots​

NázovPopis
defaultPredvolený slot pre hlavný obsah komponentu.