mbr/elm-chadcn/1.0.0

ChadCn.DropdownMenu

Provides a dropdown menu.

The implementation follows the shadcn Base UI structure and Nova defaults.

type Config msg

Describes a dropdown menu and its contents.

type alias Entry msg =
Entry (Item msg) msg

Describes one dropdown menu content element.

type Item msg

Describes an interactive dropdown menu item.

= Default
| Destructive

Controls a dropdown menu item's semantic appearance.

type Model

Holds dropdown menu interaction and positioning state.

type Msg

Describes messages handled by a dropdown menu.

init : String -> Model

Creates closed dropdown menu state with a stable DOM identifier.

new : (Msg -> msg) -> (List (Attribute msg) -> Html msg) -> Config msg

Creates a dropdown configuration with a composed trigger.

withAlign : Align -> Config msg -> Config msg

Sets the popup's alignment.

withAlignOffset : Float -> Config msg -> Config msg

Offsets the popup along its alignment axis.

withContent : List (Entry msg) -> Config msg -> Config msg

Sets the popup's content.

withContentAttributes : List (Attribute msg) -> Config msg -> Config msg

Adds attributes to the popup.

withSide : Side -> Config msg -> Config msg

Sets the preferred side of the popup.

withSideOffset : Float -> Config msg -> Config msg

Sets the distance between the trigger and popup.

isOpen : Model -> Bool

Returns whether the dropdown menu is open.

Closes the dropdown menu without moving focus.

subscriptions : Config msg -> Model -> Sub msg

Subscribes to dismissal and repositioning events while open.

update : Config msg -> Msg -> Model -> ( Model, Cmd msg )

Applies a dropdown menu message.

view : Model -> Config msg -> Html msg

Renders a dropdown menu.

newItem : String -> msg -> List (Html msg) -> Item msg

Creates an enabled menu item.

withItemAttributes : List (Attribute msg) -> Item msg -> Item msg

Adds attributes to a menu item.

withItemDisabled : Bool -> Item msg -> Item msg

Controls whether a menu item accepts interaction.

withItemInset : Bool -> Item msg -> Item msg

Controls whether a menu item is inset.

Sets a menu item's semantic appearance.

item : Item msg -> Entry msg

Adds an item to declarative menu content.

group : List (Attribute msg) -> List (Entry msg) -> Entry msg

Creates a group of related menu entries.

label : List (Attribute msg) -> List (Html msg) -> Entry msg

Creates a menu group label.

separator : List (Attribute msg) -> Entry msg

Creates a menu separator.

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

Renders a menu shortcut.