V Vaylan UI
Actions

Swap

Switch between two clear visual states with a single control.

Preview

Change the example value; the preview reports the current state.

Example

<.swap label="Theme"><:on>Dark</:on><:off>Light</:off></.swap>

API contract

swap/1 uses declared Phoenix attributes and slots. This table is generated from the compiled component metadata.

AttributeTypeRequiredDefault Accepted values
label :string Yes — Any value matching the declared type
active :boolean No false Any value matching the declared type
style :atom No nil [nil, :rotate, :flip]
class :any No nil Any value matching the declared type
rest :global No — Any value matching the declared type
SlotRequiredSlot attributes
on Yes No slot attributes
off Yes No slot attributes
indeterminate No No slot attributes

States and behavior

Default and caller-supplied variants preserve semantic daisyUI colors and additive classes.

Keyboard and accessibility

Behavioral tests

These automated checks are applied to this component by the package and documentation test suites.

  • ExUnit

    Swap state content

    Renders on and off content with the selected rotation or flip behavior and an accessible control label.

    test/vaylan_ui/catalog_test.exs
  • Docs

    Preview behavior contract

    Classified as input. Change the example value; the preview reports the current state.

    examples/docs/test/vaylan_ui_docs_web/controllers/page_controller_test.exs
  • Docs

    Stable public component page

    Renders the component name, example, API contract, accepted values, and keyboard and accessibility guidance at its stable URL.

    examples/docs/test/vaylan_ui_docs_web/controllers/page_controller_test.exs