avarda-ab/avarda-ui/4.0.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 msgTypeState 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

Button

type Button msgTypeState msg

Button type which can be used for type annotations when defining helpers in your code.

MsgType

MsgType which can be used for type annotations when defining helpers in your code.

MsgType which can be used for type annotations when defining helpers in your code.

#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.

withCapitalizedLabel : Bool -> Button msgTypeState msg -> Button msgTypeState msg

Capitalize the label.

withBorderRadius : Float -> Button msgTypeState msg -> Button msgTypeState msg

Explicitly set border-radius. This will override border-radius set in withBaseStyles.

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

Add additional base styles.

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

Overwrite hover styles.

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

Overwrite active styles.

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

Add additional attributes.

Button action configuration

By default, submit is used as the button action. You can change this behaviour by using either withLink or withOnClick.

<button> with onClick handler.

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