Confidenceman02/elm-select/13.0.0

Select.Styles

Add custom styling to the Select control, menu and menu item.

elm-select

Set up

Styles for the different sections of the Select all have their own configuration. This means when you are setting styles to the MenuConfig you can only use the Setters for the MenuConfig.

NOTE: The native Select variant only respects some of the styles.

type Config
{ inset :
{ offsetX : Float
, offsetY : Float
, blurRadius : Float
, spreadRadius : Float
, color : Color
}
, activeBorder :
{ offsetX : Float
, offsetY : Float
, blurRadius : Float
, spreadRadius : Float
, color : Color
}
, shadow :
{ offsetX : Float
, offsetY : Float
, blurRadius : Float
, spreadRadius : Float
, color : Color
}
}

Borders are implemented using the "border-as-shadow" technique instead of standard border properties.

Shadows don't affect a box models dimensions preventing annoying pixel jumps.

Elm-select uses 3 box shadow layers to implement the border:

- The inset
- The active border
- The shadow

The default styling for the select

This is the Config that all select variants use if no styles have been configured.

Constants

Setters

Set styles

Control

Set styles for the select control

    controlBranding : ControlConfig
    controlBranding =
        getControlConfig default
            |> setControlBorderColor (Css.hex "#FFFFFF")
            |> setControlBorderColorFocus (Css.hex "#0168B3")


    selectBranding : Config
    selectBranding
        default
            |> setControlStyles controlBranding
setControlBorderColor : BorderColorConfiguration -> ControlConfig -> ControlConfig
setControlBorderColorFocus : BorderColorConfiguration -> ControlConfig -> ControlConfig

Menu

Set styles for the Select menu

    menuBranding : MenuConfig
    menuBranding =
        getMenuConfig default
            |> setMenuBackgroundColor (Css.hex "#000000")
            |> setMenuBorderRadius 4




    selectBranding : Config
    selectBranding
        default
            |> setMenuStyles menuBranding
setMenuControlBorderColor : BorderColorConfiguration -> MenuConfig -> MenuConfig

Group

Set styles for Select menu item groups

    groupBranding : GroupConfig
    groupBranding =
        getGroupConfig default
            |> setGroupColor (Css.hex "#000000")




    selectBranding : Config
    selectBranding
            default
                |> setGroupStyles groupBranding

Menu item

Set styles for Select menu item

    menuItemBranding : MenuItemConfig
    menuItemBranding =
        getMenuItemConfig default
            |> setMenuItemBackgroundColor (Css.hex "#000000")




    selectBranding : Config
    selectBranding
            default
                |> setMenuItemStyles menuItemBranding
setMenuControlBorderColorFocus : BorderColorConfiguration -> MenuConfig -> MenuConfig

Getters

Get styles

Control

Get the ControlConfig

baseStyles : Config
baseStyles =
    default


baseControlStyles : ControlConfig
baseControlStyles =
    getControlConfig baseStyles
        |> setControlBorderColor (Css.hex "ffffff")
getControlBorderColor : ControlConfig -> BorderColorConfiguration
getControlBorderColorFocus : ControlConfig -> BorderColorConfiguration

Menu

Get the MenuConfig

baseStyles : Config
baseStyles =
    default


baseMenuStyles : MenuConfig
baseMenuStyles =
    getMenuConfig baseStyles
        |> setMenuBorderRadius 4
getMenuControlBorderColor : MenuConfig -> BorderColorConfiguration
getMenuControlBorderColorFocus : MenuConfig -> BorderColorConfiguration
getMenuMaxHeightRawType : MenuConfig -> LengthOrNoneOrMinMaxDimension
getMenuPosition : MenuConfig -> Position {}

Group

Get the GroupConfig

baseStyles : Config
baseStyles =
    default


baseGroupStyles : GroupConfig
baseGroupStyles =
    getGroupConfig baseStyles
        |> setGroupColor (Css.hex "#000000")

Menu item

Get the MenuItemConfig

baseStyles : Config
baseStyles =
    default


baseMenuStyles : MenuItemConfig
baseMenuStyles =
    getMenuItemConfig baseStyles
        |> setMenuItemBackgroundColorSelected (Css.hex "#000000")

Theme

A fun dark theme

elm-select

For the Bootstrap4 lovers