# `Plushie.Type.StyleMap`
[🔗](https://github.com/plushie-ui/plushie-elixir/blob/v0.6.0/lib/plushie/type/style_map.ex#L1)

Per-instance widget styling that crosses the IPC boundary as a plain map.

A `StyleMap` lets you override visual properties (background, text color,
border, shadow) on individual widget instances without defining a named
style. Status overrides (`hovered`, `pressed`, `disabled`, `focused`) apply
partial style changes for those interaction states.

The `background` field accepts either a solid color (hex string or named
atom) or a `Plushie.Type.Gradient` for gradient fills.

## Wire format

    %{
      background: "#ff0000",
      text_color: "#ffffff",
      border: %{color: "#000000", width: 1, radius: 4},
      hovered: %{background: "#cc0000"},
      pressed: %{background: "#990000"}
    }

## Example

    style = Plushie.Type.StyleMap.new()
            |> Plushie.Type.StyleMap.background("#3366ff")
            |> Plushie.Type.StyleMap.text_color(:white)
            |> Plushie.Type.StyleMap.hovered(%{background: "#5588ff"})

    Button.new("btn", "Click me", style: style)

Gradient backgrounds work the same way:

    gradient = Plushie.Type.Gradient.linear(90, [{0.0, "#ff0000"}, {1.0, "#0000ff"}])

    style = Plushie.Type.StyleMap.new()
            |> Plushie.Type.StyleMap.background(gradient)

    Container.new("ctr", [], style: style)

# `status_override`

```elixir
@type status_override() :: %{
  optional(:background) =&gt; Plushie.Type.Color.t() | Plushie.Type.Gradient.t(),
  optional(:text_color) =&gt; Plushie.Type.Color.t(),
  optional(:border) =&gt; Plushie.Type.Border.t(),
  optional(:shadow) =&gt; Plushie.Type.Shadow.t()
}
```

Partial style override for an interaction state.

# `t`

```elixir
@type t() :: %Plushie.Type.StyleMap{
  background: Plushie.Type.Color.t() | Plushie.Type.Gradient.t() | nil,
  base: atom() | nil,
  border: Plushie.Type.Border.t() | nil,
  disabled: status_override() | nil,
  focused: status_override() | nil,
  hovered: status_override() | nil,
  pressed: status_override() | nil,
  shadow: Plushie.Type.Shadow.t() | nil,
  text_color: Plushie.Type.Color.t() | nil
}
```

# `background`

```elixir
@spec background(
  style_map :: t(),
  background :: Plushie.Type.Color.input() | Plushie.Type.Gradient.t()
) ::
  t()
```

Sets the background. Accepts a color (any form `Color.cast/1` supports) or a `Gradient`.

# `base`

```elixir
@spec base(style_map :: t(), preset :: atom()) :: t()
```

Sets the base preset to extend from instead of starting from the widget default.

# `border`

```elixir
@spec border(style_map :: t(), border :: Plushie.Type.Border.t()) :: t()
```

Sets the border specification.

# `disabled`

```elixir
@spec disabled(style_map :: t(), disabled :: status_override() | keyword()) :: t()
```

Sets the disabled status override. Accepts a map or keyword list.

# `focused`

```elixir
@spec focused(style_map :: t(), focused :: status_override() | keyword()) :: t()
```

Sets the focused status override. Accepts a map or keyword list.

# `from_opts`

```elixir
@spec from_opts(opts :: keyword()) :: t()
```

Constructs a `StyleMap` from a keyword list.

# `hovered`

```elixir
@spec hovered(style_map :: t(), hovered :: status_override() | keyword()) :: t()
```

Sets the hovered status override. Accepts a map or keyword list.

# `new`

```elixir
@spec new() :: t()
```

Creates an empty style map.

# `pressed`

```elixir
@spec pressed(style_map :: t(), pressed :: status_override() | keyword()) :: t()
```

Sets the pressed status override. Accepts a map or keyword list.

# `shadow`

```elixir
@spec shadow(style_map :: t(), shadow :: Plushie.Type.Shadow.t()) :: t()
```

Sets the shadow specification.

# `text_color`

```elixir
@spec text_color(style_map :: t(), text_color :: Plushie.Type.Color.input()) :: t()
```

Sets the text color. Accepts a hex string or named color atom.

---

*Consult [api-reference.md](api-reference.md) for complete listing*
