This library adds an accordion element that toggles showing or hiding the content by increasing or decreasing its height.
Getting started
Installation
elm install hallelujahdrive/elm-accordion@1.0.4
This library relies on additional JavaScript and CSS. Your project must load them in one of the following ways.
Embedding in HTML
The easy way is to add the following elements to your page:
<link rel="stylesheet" type="text/css" href="https://unpkg.com/elm-accordion@1.0.4/dist/elm-accordion.min.css" />
<script src="https://unpkg.com/elm-accordion@1.0.4/dist/elm-accordion.min.js"></script>
Using bundler
If you want to use a bundler like webpack you can install the package from npm:
npm install elm-accordion@1.0.4
And in your Javascript add the following import:
require("elm-accordion/dist/elm-accordion.min.js");
require("elm-accordion/dist/elm-accordion.min.css");
Simple Usage
Write code like the following. Check the Documentation for more information on the module.
import Accordion
type alias Model = Bool
type Msg = Toggled
update msg model =
case msg of
Toggled ->
( model = not model
, Cmd.none
)
view model =
Accordion.accordion
[]
( Accordion.head
[ onClick Toggled ]
[ text "Accordion head content" ]
)
( Accordion.body [] [ text "Accordion body content" ] )
model
Documentation
Accordion
Accordion Head
Accordion head type
Accordion head constructor
attributes
List of attributeschildren
List of child elements
Accordion Body
Accordion body type
Accordion.List
The status of multiple accordions can be managed collectively and linked.
Status
Multiple accordions status type
Initialize multiple open Status.
values
List of values associated with open accordions(e.g. List ofid
).
Initialize single open Status.
value
A value of associated with open accordion(e.g.id
).
Update Status
Toggle the state of the argument value.
Check status
Examples
Simple Accordion
Simple accordion with text content only.
Accordion customization
You can set any element on the head and body of the accordion. If you want to change the style of the open accordion, specify .elm-accordion--open
in the class selector.
List of accordions
Controls the status of multiple Accordions collectively.
Browser support
This library is implemented using custom elements
. Check the support status of Custom Elements(V1) for each broser.
License
This library is licensed under MIT License.
Contributions
Please submit your feedback using this library to GitHub.
Accordion view function.
attributes
List of attributeshead
An accordion head element.body
An accordion body element.open
Specify whether a dailog is open