Web browsers and adaptive devices use attributes to apply default styling and build interactive functionality into HTML markup. For example, adding a title attribute to an element will cause browsers to display a tooltip with the title value when the user hovers over that element. This module provides a compact but flexible syntax for adding HTML attributes to UI elements.
Add a list of attributes to a UI element
myPhoto
|> Ui.Attribute.addList
[ ("title", Dom.Property.string "My summer vaction")
, ("hidden", Dom.Property.bool True)
]Convenience function to set the title property
myPhoto
|> Ui.Attribute.title "My summer vacation"Convenience function to set the ARIA role attribute
myElement
|> Ui.Attribute.role "presentation"Convenience function to set the aria-label attribute
myNavbar
|> Ui.Attribute.ariaLabel "Main navigation"Convenience function to set the aria-labelledby attribute
myFigure
|> Ui.Attribute.ariaLabelledBy "figure-caption-3"Convenience function to set the aria-describedby attribute
myPhoto
|> Ui.Attribute.ariaDescribedBy "article-section-5"Convenience function to set aria-hidden="true"
decorativeIcon
|> Ui.Attribute.ariaHidden
Add a single attribute to a UI element. The first argument in the tuple gives the attribute name. For the second argument in the tuple, use one of the functions in Dom.Property or Dom.Attribute from danielnarey/elm-semantic-dom to specify how the attribute value should be assigned (see the documentation in these modules).
Alternatively, if it makes more sense to you, you could use the function this way with the same result: