Configure alert to use primary colors.
Provide contextual feedback messages for typical user actions with the handful of available and flexible alert messages.
When you just need a simple alert, these shorthand functions lets you quickly display an alert.
simplePrimary [] [ text "I'm a simple alert!" ]
simpleWarning
[ class "myCustomAlertClass" ]
[ Alert.h1 [] [ text "Alert heading" ]
, p [] [ text "Some alert content." ]
, Alert.link [ href "#somewhere" ] [ text "Styled link" ]
]Show an elert using secondary color.
attributes - List of attributes to customize the alert containerchildren - List of child html elementsShow an elert using success color.
attributes - List of attributes to customize the alert containerchildren - List of child html elementsShow an elert using info color.
attributes - List of attributes to customize the alert containerchildren - List of child html elementsShow an elert using warning color.
attributes - List of attributes to customize the alert containerchildren - List of child html elementsShow an elert using danger color.
attributes - List of attributes to customize the alert containerchildren - List of child html elementsShow an elert using light color.
attributes - List of attributes to customize the alert containerchildren - List of child html elementsShow an elert using dark color.
attributes - List of attributes to customize the alert containerchildren - List of child html elementsThese functions allow you to create alert children with alert specific styling
To get proper link colors for a elements use this function
attributes List of attributes for the link elementchildren List of child elementsAlert h1 header with appropriate color styling
attributes List of attributeschildren List of child elementsAlert h2 header with appropriate color styling
attributes List of attributeschildren_ List of child elementsAlert h3 header with appropriate color styling
attributes List of attributeschildren_ List of child elementsAlert h3 header with appropriate color styling
attributes List of attributeschildren_ List of child elementsAlert h5 header with appropriate color styling
attributes List of attributeschildren_ List of child elementsAlert h6 header with appropriate color styling
attributes List of attributeschildren_ List of child elementsDismissable alerts are also supported. You can even configure them to have a fade out animation when dismissed. Unlike it's Twitter Bootstrap JavaScript counterpart we can't remove the alert element from the DOM. It's simply set to display:none. To support dismissable alerts you must keep track of the alerts visibility in your model.
type alias Model =
{ alertVisibility : Alert.Visibility }
type Msg
= AlertMsg Alert.Visibility
init : ( Model, Cmd Msg )
init =
( { alertVisibility = Alert.shown }
, Cmd.none
)
update : Msg -> Model -> ( Model, Cmd Msg )
update msg model =
case msg of
AlertMsg visibility ->
( { model | alertVisibility = visibility }, Cmd.none )
view : Model -> Html Msg
view model =
Alert.config
|> Alert.dismissableWithAnimation AlertMsg
|> Alert.info
|> Alert.children
[ Alert.h4 [] [ text "Alert heading" ]
, Alert.text "This info message has a "
, Alert.link [ href "javascript:void()" ] [ text "link" ]
, Alert.p [] [ text "Followed by a paragraph behaving as you'd expect." ]
]
|> Alert.view model.alertVisibility
-- Subscriptions are only needed when you choose to use dismissableWithAnimation
subscriptions : Model -> Sub Msg
subscriptions model =
Alert.subscriptions model.alertVisibility AlertMsgCall the view function to turn an alert config into an Elm Html element.
visibility The current visibility for the alert.config Configuration settings and child elements for your alert.Opaque type used for describing the configuration of an alert.
Use this function to represent the shown state for an alert.
Use this function to represent the closed/dismissed state for an alert.
Opaque type used to represent whether to display the alert or not.
Make the alert dismissable. Adds a close icon top right. You'll need to handle the msg in your update function.
type Msg
= AlertMsg Alert.Visibilty
-- somewhere in your view function where you display the alert
Alert.config
|> Alert.dismissable AlertMsg
|> ... etcEnable a fade out animation when closing/dismissing an Alert.
Subscription for handling animations. Don't forget this when configuring your alert to be dismissable with animation.
subscriptions : Model -> Sub Msg
subscriptions model =
Alert.subscriptions model.alertVisibility AlertMsg
Show an elert using primary color.
attributes- List of attributes to customize the alert containerchildren- List of child html elements