aforemny/material-components-web-elm/2.1.0

NOTE: the latest version is 9.1.0

Material.LayoutGrid

Material design’s responsive UI is based on a column-variate grid layout. It has 12 columns on desktop, 8 columns on tablet and 4 columns on phone.

Table of Contents

Resources

Basic Usage

import Material.LayoutGrid as LayoutGrid
    exposing
        ( layoutGrid
        , layoutGridCell
        , layoutGridInner
        )


main =
    layoutGrid []
        [ layoutGridInner []
            [ layoutGridCell [] []
            , layoutGridCell [] []
            , layoutGridCell [] []
            ]
        ]

Layout Grid

layoutGrid : List (Attribute msg) -> List (Html msg) -> Html msg

Grid view function

layoutGridCell : List (Attribute msg) -> List (Html msg) -> Html msg

Cell view function

layoutGridInner : List (Attribute msg) -> List (Html msg) -> Html msg

Mandatory wrapper around layoutGridCell

Cell Spans

Cells span by default four columns within the grid. Use one of the following functions to change this behavior.

span1 : Attribute msg

Change a cell to span one column

span2 : Attribute msg

Change a cell to span two columns

span3 : Attribute msg

Change a cell to span three columns

span4 : Attribute msg

Change a cell to span four columns

span5 : Attribute msg

Change a cell to span five columns

span6 : Attribute msg

Change a cell to span six columns

span7 : Attribute msg

Change a cell to span seven columns

span8 : Attribute msg

Change a cell to span eight columns

span9 : Attribute msg

Change a cell to span nine columns

span10 : Attribute msg

Change a cell to span ten columns

span11 : Attribute msg

Change a cell to span eleven columns

span12 : Attribute msg

Change a cell to span twelve columns

Cell Alignment

Cells are by default stretched. You can add attributes alignTop, alignMiddle or alignBottom to a cell to change this behavior.

alignTop : Attribute msg

Aligns a cell to the top

alignMiddle : Attribute msg

Aligns a cell to the middle

alignBottom : Attribute msg

Aligns a cell to the bottom

Grid Alignment

The layout grid is by default center aligned. You can add attributes alignLeft or alignRight to the layoutGrid to change this behavior.

Note that effects will only be visible if the layout grid does not span the entire available width.

alignLeft : Attribute msg

Aligns the layout grid to the left

alignRight : Attribute msg

Aligns the layout grid to the right

Nested Grid

When your contents need extra structure that cannot be supported by a single layout grid, you can nest layout grids within each other. To nest layout grid, add a new layoutGridInner around nested layoutGridCells within an existing layoutGridCell.

The nested layout grid behaves exactly like when they are not nested, e.g, they have 12 columns on desktop, 8 columns on tablet and 4 columns on phone. They also use the same gutter size as their parents, but margins are not re-introduced since they are living within another cell.

However, the Material Design guidelines do not recommend having a deeply nested grid as it might mean an over complicated UX.

layoutGrid []
    [ layoutGridInner []
        [ layoutGridCell []
            [ layoutGridInner []
                [ layoutGridCell [] []
                , layoutGridCell [] []
                ]
            ]
        , layoutGridCell [] []
        ]
    ]

Device-Specific Cell Spans

Desktop Cell Spans

span1Desktop : Attribute msg

Change a cell to span one column (desktop only)

span2Desktop : Attribute msg

Change a cell to span two columns (desktop only)

span3Desktop : Attribute msg

Change a cell to span three columns (desktop only)

span4Desktop : Attribute msg

Change a cell to span four columns (desktop only)

span5Desktop : Attribute msg

Change a cell to span five columns (desktop only)

span6Desktop : Attribute msg

Change a cell to span six columns (desktop only)

span7Desktop : Attribute msg

Change a cell to span seven columns (desktop only)

span8Desktop : Attribute msg

Change a cell to span eight columns (desktop only)

span9Desktop : Attribute msg

Change a cell to span nine columns (desktop only)

span10Desktop : Attribute msg

Change a cell to span ten columns (desktop only)

span11Desktop : Attribute msg

Change a cell to span eleven columns (desktop only)

span12Desktop : Attribute msg

Change a cell to span twelve columns (desktop only)

Tablet Cell Spans

span1Tablet : Attribute msg

Change a cell to span one column (tablet only)

span2Tablet : Attribute msg

Change a cell to span two columns (tablet only)

span3Tablet : Attribute msg

Change a cell to span three columns (tablet only)

span4Tablet : Attribute msg

Change a cell to span four columns (tablet only)

span5Tablet : Attribute msg

Change a cell to span five columns (tablet only)

span6Tablet : Attribute msg

Change a cell to span six columns (tablet only)

span7Tablet : Attribute msg

Change a cell to span seven columns (tablet only)

span8Tablet : Attribute msg

Change a cell to span eight columns (tablet only)

Phone Cell Spans

span1Phone : Attribute msg

Change a cell to span one column (phone only)

span2Phone : Attribute msg

Change a cell to span two columns (phone only)

span3Phone : Attribute msg

Change a cell to span three columns (phone only)

span4Phone : Attribute msg

Change a cell to span four columns (phone only)