# `Toddy.Iced.Widget.QrCode`
[🔗](https://github.com/toddy-ui/toddy-elixir/blob/v0.3.0/lib/toddy/iced/widget/qr_code.ex#L1)

QR Code -- renders a QR code from a data string.

Uses the iced canvas to draw a grid of cells representing the encoded data.

## Props

- `data` (string) -- the data to encode in the QR code. Required.
- `cell_size` (number) -- size of each QR module in pixels. Default: 4.0.
- `cell_color` (color) -- color of dark modules. Default: black.
- `background_color` (color) -- color of light modules. Default: white.
- `error_correction` (atom) -- error correction level. One of `:low`,
  `:medium` (default), `:quartile`, `:high`.
- `a11y` (map) -- accessibility overrides. See `Toddy.Iced.A11y`.

# `error_correction`

```elixir
@type error_correction() :: :high | :quartile | :medium | :low
```

# `option`

```elixir
@type option() ::
  {:cell_size, number()}
  | {:cell_color, Toddy.Iced.Color.input()}
  | {:background_color, Toddy.Iced.Color.input()}
  | {:error_correction, error_correction()}
  | {:a11y, Toddy.Iced.A11y.t()}
```

# `t`

```elixir
@type t() :: %Toddy.Iced.Widget.QrCode{
  a11y: Toddy.Iced.A11y.t() | nil,
  background_color: Toddy.Iced.Color.t() | nil,
  cell_color: Toddy.Iced.Color.t() | nil,
  cell_size: number() | nil,
  data: String.t(),
  error_correction: error_correction() | nil,
  id: String.t()
}
```

# `a11y`

```elixir
@spec a11y(qr_code :: t(), a11y :: Toddy.Iced.A11y.t()) :: t()
```

Sets accessibility annotations.

# `background_color`

```elixir
@spec background_color(qr_code :: t(), background_color :: Toddy.Iced.Color.input()) ::
  t()
```

Sets the background color (light modules).

# `build`

```elixir
@spec build(qr_code :: t()) :: Toddy.Iced.ui_node()
```

Converts this QR code struct to a `ui_node()` map via the `Toddy.Iced.Widget` protocol.

# `cell_color`

```elixir
@spec cell_color(qr_code :: t(), cell_color :: Toddy.Iced.Color.input()) :: t()
```

Sets the color of dark modules.

# `cell_size`

```elixir
@spec cell_size(qr_code :: t(), cell_size :: number()) :: t()
```

Sets the cell size (pixels per QR module).

# `error_correction`

```elixir
@spec error_correction(qr_code :: t(), error_correction :: error_correction()) :: t()
```

Sets the error correction level.

# `new`

```elixir
@spec new(id :: String.t(), data :: String.t(), opts :: [option()]) :: t()
```

Creates a new QR code struct with the given data string and optional keyword opts.

# `with_options`

```elixir
@spec with_options(qr_code :: t(), opts :: [option()]) :: t()
```

Applies keyword options to an existing QR code struct.

---

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