betagouv/elm-dsfr/5.0.0

NOTE: the latest version is 5.2.0

BetaGouv.DSFR.Input

Création

new :
{ onInput : String -> msg
, id : String
, label : Html Never
, value : String
}
-> Config msg

Crée un champ de saisie

Input.new
    { onInput = UpdateDate
    , id = "date"
    , label = text "Date"
    , value = date
    }
    |> Input.date
    |> Input.view
view : Config msg -> Html msg

Types de champ de saisie

textArea : Maybe Int -> Config msg -> Config msg

Définit un champ de saisie de type textarea

Input.new
    { onInput = UpdateComment
    , id = "commentaire"
    , label = text "Commentaire"
    , value = value
    }
    |> Input.textArea (Just 8)
    |> Input.withExtraAttrs [ class "w-full" ]
    |> Input.view
date : Config msg -> Config msg
email : Config msg -> Config msg
numeric : Config msg -> Config msg
decimal : Float -> Config msg -> Config msg

Définit un champ de saisie décimal

Input.new
    { onInput = UpdateCost
    , id = "cost"
    , label = text "Coût"
    , value = cost
    }
    |> Input.decimal 0.01
    |> Input.view


`Input.decimal 0.01` signifie une précision à deux décimales après la virgule.
password : Config msg -> Config msg
textDisplay : Config msg -> Config msg
text : Config msg -> Config msg
custom : String -> Config msg -> Config msg

Définit un champ de saisie personnalisé

Input.new
    { onInput = UpdatePhone
    , id = "phone"
    , label = text "Numéro de téléphone"
    , value = value
    }
    |> Input.custom "tel"
    |> Input.view

Configuration

withDisabled : Bool -> Config msg -> Config msg
withValid : Maybe (List (Html msg)) -> Config msg -> Config msg
withError : Maybe (List (Html msg)) -> Config msg -> Config msg
withHint : List (Html Never) -> Config msg -> Config msg
withReadonly : Bool -> Config msg -> Config msg
withType : InputType -> Config msg -> Config msg
withIcon : Maybe String -> Config msg -> Config msg
withInputAttrs : List (Attribute msg) -> Config msg -> Config msg
withExtraAttrs : List (Attribute Never) -> Config msg -> Config msg

Type

type alias Config msg =
{ mandatory : MandatoryInputConfig msg
, optional : OptionalInputConfig msg
}