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

Colors

When to use

Use wje-toggle when users need to enter values, choose options, or trigger form-related actions.

When not to use

Do not use it as a decorative element without interaction. Prefer presentational components in that case.

Accessibility

Always provide a label (label/aria-label), keep keyboard support, and surface clear validation feedback.

Best Practices

  • Keep validation rules and error behavior consistent across the entire form.
  • Show loading or disabled states during async operations.
  • Split complex forms into smaller sections with immediate feedback.

Attributes and Properties

checked

DescriptionGet checked attribute.
Attributechecked
Typeboolean
Default-

disabled

DescriptionDisables user interaction with the component.
Attributedisabled
Typeany
Default-

required

DescriptionMarks the component as required for form validation.
Attributerequired
Typeany
Default-

Events

NameDescription
wje-toggle:inputEmitted when the input value changes.
wje-toggle:changeEmitted when the component value changes.

Methods

No public methods available for this component.

CSS Shadow Parts

NameDescription
nativeThe native toggle wrapper.
inputThe toggle input.
toggleThe toggle part.

CSS Custom Properties

NameDescription
--wje-toggle-color-baseThe base background color of the toggle. Defines the default background color when the toggle is in an unselected state.
--wje-toggle-widthThe overall width of the toggle switch. Determines how wide the toggle component appears.
--wje-toggle-heightThe overall height of the toggle switch. Specifies how tall the toggle component appears.
--wje-toggle-border-radiusThe border radius of the toggle. Controls how rounded the corners of the toggle are.
--wje-toggle-handle-widthThe width of the toggle handle (knob). Determines the size of the handle for user interaction.
--wje-toggle-handle-heightThe height of the toggle handle (knob). Specifies the vertical size of the handle.
--wje-toggle-handle-border-radiusThe border radius of the toggle handle. Controls how rounded the handle is.
--wje-toggle-handle-colorThe color of the toggle handle. Accepts any valid CSS color, such as hex, rgb, or css variable.
--wje-toggle-handle-shadowThe shadow applied to the toggle handle. Adds a subtle shadow effect for better visual clarity.
--wje-toggle-handle-shadow-checkedThe shadow applied to the toggle handle when it is in the checked (on) state. Provides visual feedback to indicate the toggle state.
--wje-toggle-durationThe duration of the toggle animation in milliseconds. Controls how long the toggle animation lasts during state changes.
--wje-toggle-curveThe easing curve used for the toggle animation. Defines the speed curve for the animation, enhancing the user experience with smooth transitions.

Slots

NameDescription
defaultThe default slot for the toggle.