avarda-ab/avarda-ui/3.2.0

NOTE: the latest version is 5.0.3

AvardaUi.Button

This module provides a styled button component with optional left/right icon. It uses the builder pattern:

  1. Start with new to create a base input.
  2. Chain configuration functions like withIsDisabled or withLeftChild.
  3. Finish with view to render it.

Creating an Button

new : { label : String } -> Button MsgTypeUnset msg

Create a new Button component.

AvardaUi.Button.new
    { label = "Click me" }
view : Button MsgTypeSet msg -> Html msg

Render the Button as HTML.

Always call this after you've built up the button with new and chained settings.

AvardaUi.Button.new {...}
    |> AvardaUi.Button.withIsRequired True
    |> AvardaUi.Select.view

#Variant

type Variant
= Primary
| Secondary
| Tertiary

Style variants of the button. This is used with withVariant

Configuration

withVariant : Variant -> Button msgTypeState msg -> Button msgTypeState msg

Change button variant (Variant). Primary is set by default.

withLeftChild : Html msg -> Button msgTypeState msg -> Button msgTypeState msg

Add a left-side child element, preferably an icon.

withRightChild : Html msg -> Button msgTypeState msg -> Button msgTypeState msg

Add a right-side child element, preferably an icon.

withIsDisabled : Bool -> Button msgTypeState msg -> Button msgTypeState msg

Disable the button. Visually dims and prevents user actions.

withSizeLarge : Button msgTypeState msg -> Button msgTypeState msg

Change button sizing to large (default).

withSizeMedium : Button msgTypeState msg -> Button msgTypeState msg

Change button sizing to medium.

withSizeSmall : Button msgTypeState msg -> Button msgTypeState msg

Change button sizing to small.

withBaseStyles : List Style -> Button msgTypeState msg -> Button msgTypeState msg

Overwrite or add additional base styles.

withHoverStyles : List Style -> Button msgTypeState msg -> Button msgTypeState msg

Overwrite or add additional hover styles.

List (Attribute msg)
-> Button msgTypeState msg
-> Button msgTypeState msg

Add additional attributes.

withMsgTypeOnClick : msg -> Button MsgTypeUnset msg -> Button MsgTypeSet msg

<button> with onClick handler.

withMsgTypeSubmit : Button MsgTypeUnset msg -> Button MsgTypeSet msg

<button> with type = "submit". This the default button type.