mbr/elm-chadcn/1.0.0

ChadCn.Select

Provides a select.

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

type Config msg

Describes a complete select control.

type alias Entry msg =
Entry (Item msg) msg

Describes one declarative select entry.

type Item msg

Describes one selectable item.

type Model

Holds select interaction state.

type Msg

Describes messages handled by a select.

type Size
= Default
| Small

Controls trigger sizing.

init : String -> Maybe String -> Model

Creates closed select state with a stable DOM identifier and optional value.

new : (Msg -> msg) -> (String -> msg) -> Config msg

Creates an empty select configuration.

withAlign : Align -> Config msg -> Config msg

Sets the popup alignment.

withAlignOffset : Float -> Config msg -> Config msg

Offsets the popup along its alignment axis.

withAriaLabel : String -> Config msg -> Config msg

Sets the trigger's accessible label.

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

Sets the complete select content.

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

Adds native attributes to the popup.

withDisabled : Bool -> Config msg -> Config msg

Sets whether the select accepts interaction.

withPlaceholder : String -> Config msg -> Config msg

Sets placeholder text shown without a selection.

withSide : Side -> Config msg -> Config msg

Sets the preferred popup side.

withSideOffset : Float -> Config msg -> Config msg

Sets the distance between the trigger and popup.

withSize : Size -> Config msg -> Config msg

Sets the trigger size.

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

Adds native attributes to the trigger.

addEntry : Entry msg -> Config msg -> Config msg

Appends one entry to the select content.

newItem : String -> String -> Item msg

Creates an enabled item whose visible content is its label.

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

Adds native attributes to an item.

withItemContent : List (Html msg) -> Item msg -> Item msg

Replaces an item's visible content while retaining its accessible label.

withItemDisabled : Bool -> Item msg -> Item msg

Sets whether an item can be selected.

item : Item msg -> Entry msg

Converts an item to declarative select content.

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

Creates a group of related select entries.

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

Creates a select group label.

separator : List (Attribute msg) -> Entry msg

Creates a select separator.

isOpen : Model -> Bool

Returns whether the popup is open.

selected : Model -> Maybe String

Returns the selected item value.

setSelected : Maybe String -> Model -> Model

Replaces the selected value without emitting a change callback.

subscriptions : Config msg -> Model -> Sub msg

Subscribes to dismissal and repositioning while open.

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

Applies a select event.

view : Model -> Config msg -> Html msg

Renders the select trigger and optional popup.