This library lets you use automatically expanding textareas in Elm. This means the textarea grows in height until it reaches the maximum number of rows allowed and then becomes a scrollable box.
Configuration for your textarea, describing the look and feel.
Note: Your Config should never be held in your model.
It should only appear in view code.
Create the Config for the auto expanding textarea.
A typical configuration might look like this:
type Msg
= AutoExpandInput { textValue : String, state : AutoExpand.State }
config : AutoExpand.Config Msg
config =
AutoExpand.config
{ onInput = AutoExpandInput
, padding = 10
, lineHeight = 20
, minRows = 1
, maxRows = 4
}Add the id attribute to the configuration.
myConfig
|> withId "chat-message-textarea"Add the class attribute to the configuration.
myConfig
|> withClass "textarea has-inset-shadow"Add the placeholder attribute to the configuration.
myConfig
|> withPlaceholder "Type a message here"Add inline styles for the textarea.
myConfig
|> withStyles [ ( "font-family", "sans-serif" ) ]Keeps track of how many rows we need.
Sets up the initial State for the textarea using a Config.
Show the textarea on your page.