# `Plushie.Widget.QrCode`
[🔗](https://github.com/plushie-ui/plushie-elixir/blob/v0.7.2/lib/plushie/widget/qr_code.ex#L1)

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

## Props

| Name | Type | Default | Description |
|------|------|---------|-------------|
| `data` | `String.t() \| atom()` | required | Data to encode in the QR code. Required. |
| `cell_size` | `number()` | `nil` | Size of each QR module in pixels. Default: 4.0. |
| `total_size` | `number()` | `nil` | Total size of the QR code in pixels. Derives cell_size from this. |
| `cell_color` | `String.t()` | `nil` | Color of dark modules. Default: black. |
| `background` | `String.t()` | `nil` | Color of light modules. Default: white. |
| `error_correction` | `:low \| :medium \| :quartile \| :high` | `nil` | Error correction level: `:low`, `:medium`, `:quartile`, `:high`. |
| `alt` | `String.t() \| atom()` | `nil` | Accessible label for the QR code. |
| `description` | `String.t() \| atom()` | `nil` | Extended accessible description. |
| `event_rate` | `integer()` | `nil` | Max events per second for coalescable events. |
| `a11y` | `%Plushie.Type.A11y{} \| map() \| keyword()` | `%{role: :image}` | Accessibility annotations. |

## Constructor

    QrCode.new(id, data)
    QrCode.new(id, data, opts)

# `option`

```elixir
@type option() ::
  ((((((({:cell_size, number()} | {:total_size, number()})
        | {:cell_color, atom() | String.t() | map()})
       | {:background, atom() | String.t() | map()})
      | {:error_correction, :low | :medium | :quartile | :high})
     | {:alt, String.t() | atom()})
    | {:description, String.t() | atom()})
   | {:event_rate, integer()})
  | {:a11y,
     %Plushie.Type.A11y{
       active_descendant: term(),
       busy: term(),
       described_by: term(),
       description: term(),
       disabled: term(),
       error_message: term(),
       expanded: term(),
       has_popup: term(),
       hidden: term(),
       invalid: term(),
       label: term(),
       label_from: term(),
       labelled_by: term(),
       level: term(),
       live: term(),
       mnemonic: term(),
       modal: term(),
       orientation: term(),
       position_in_set: term(),
       radio_group: term(),
       read_only: term(),
       required: term(),
       role: term(),
       selected: term(),
       size_of_set: term(),
       toggled: term(),
       value: term()
     }
     | map()
     | keyword()}
```

# `t`

```elixir
@type t() :: %Plushie.Widget.QrCode{
  a11y:
    (%Plushie.Type.A11y{
       active_descendant: term(),
       busy: term(),
       described_by: term(),
       description: term(),
       disabled: term(),
       error_message: term(),
       expanded: term(),
       has_popup: term(),
       hidden: term(),
       invalid: term(),
       label: term(),
       label_from: term(),
       labelled_by: term(),
       level: term(),
       live: term(),
       mnemonic: term(),
       modal: term(),
       orientation: term(),
       position_in_set: term(),
       radio_group: term(),
       read_only: term(),
       required: term(),
       role: term(),
       selected: term(),
       size_of_set: term(),
       toggled: term(),
       value: term()
     }
     | map()
     | keyword())
    | Plushie.Animation.Transition.t()
    | Plushie.Animation.Spring.t()
    | Plushie.Animation.Sequence.t()
    | nil,
  alt:
    (String.t() | atom())
    | Plushie.Animation.Transition.t()
    | Plushie.Animation.Spring.t()
    | Plushie.Animation.Sequence.t()
    | nil,
  background:
    String.t()
    | Plushie.Animation.Transition.t()
    | Plushie.Animation.Spring.t()
    | Plushie.Animation.Sequence.t()
    | nil,
  cell_color:
    String.t()
    | Plushie.Animation.Transition.t()
    | Plushie.Animation.Spring.t()
    | Plushie.Animation.Sequence.t()
    | nil,
  cell_size:
    number()
    | Plushie.Animation.Transition.t()
    | Plushie.Animation.Spring.t()
    | Plushie.Animation.Sequence.t()
    | nil,
  data:
    (String.t() | atom())
    | Plushie.Animation.Transition.t()
    | Plushie.Animation.Spring.t()
    | Plushie.Animation.Sequence.t()
    | nil,
  description:
    (String.t() | atom())
    | Plushie.Animation.Transition.t()
    | Plushie.Animation.Spring.t()
    | Plushie.Animation.Sequence.t()
    | nil,
  error_correction:
    (:low | :medium | :quartile | :high)
    | Plushie.Animation.Transition.t()
    | Plushie.Animation.Spring.t()
    | Plushie.Animation.Sequence.t()
    | nil,
  event_rate:
    integer()
    | Plushie.Animation.Transition.t()
    | Plushie.Animation.Spring.t()
    | Plushie.Animation.Sequence.t()
    | nil,
  id: String.t(),
  total_size:
    number()
    | Plushie.Animation.Transition.t()
    | Plushie.Animation.Spring.t()
    | Plushie.Animation.Sequence.t()
    | nil
}
```

# `a11y`

```elixir
@spec a11y(
  widget :: t(),
  value ::
    (%Plushie.Type.A11y{
       active_descendant: term(),
       busy: term(),
       described_by: term(),
       description: term(),
       disabled: term(),
       error_message: term(),
       expanded: term(),
       has_popup: term(),
       hidden: term(),
       invalid: term(),
       label: term(),
       label_from: term(),
       labelled_by: term(),
       level: term(),
       live: term(),
       mnemonic: term(),
       modal: term(),
       orientation: term(),
       position_in_set: term(),
       radio_group: term(),
       read_only: term(),
       required: term(),
       role: term(),
       selected: term(),
       size_of_set: term(),
       toggled: term(),
       value: term()
     }
     | map()
     | keyword())
    | nil
) :: t()
```

Accessibility annotations.

Accepts `%Plushie.Type.A11y{} | map() | keyword()`.

# `alt`

```elixir
@spec alt(widget :: t(), value :: (String.t() | atom()) | nil) :: t()
```

Accessible label for the QR code.

Accepts `String.t() | atom()`.

# `background`

```elixir
@spec background(widget :: t(), value :: (atom() | String.t() | map()) | nil) :: t()
```

Color of light modules. Default: white.

Accepts `String.t()`.

# `build`

```elixir
@spec build(widget :: t()) :: Plushie.Widget.ui_node()
```

Converts this widget struct to a `ui_node()` map.

# `cell_color`

```elixir
@spec cell_color(widget :: t(), value :: (atom() | String.t() | map()) | nil) :: t()
```

Color of dark modules. Default: black.

Accepts `String.t()`.

# `cell_size`

```elixir
@spec cell_size(widget :: t(), value :: number() | nil) :: t()
```

Size of each QR module in pixels. Default: 4.0.

Accepts `number()`.

# `data`

```elixir
@spec data(widget :: t(), value :: (String.t() | atom()) | nil) :: t()
```

Data to encode in the QR code. Required.

Accepts `String.t() | atom()`.

# `description`

```elixir
@spec description(widget :: t(), value :: (String.t() | atom()) | nil) :: t()
```

Extended accessible description.

Accepts `String.t() | atom()`.

# `error_correction`

```elixir
@spec error_correction(
  widget :: t(),
  value :: (:low | :medium | :quartile | :high) | nil
) :: t()
```

Error correction level: `:low`, `:medium`, `:quartile`, `:high`.

Accepts `:low | :medium | :quartile | :high`.

# `event_rate`

```elixir
@spec event_rate(widget :: t(), value :: integer() | nil) :: t()
```

Max events per second for coalescable events.

Accepts `integer()`.

# `new`

Creates a new widget struct with the given positional args and keyword options.

## Arguments

- `id` - unique widget identifier
- `data` - Data to encode in the QR code. Required.
- `opts` - keyword list of optional props

# `qr_code`
*macro* 

Creates a `:qr_code` widget.

Shorthand for `new/2`. Import this macro to use the widget name
directly in view functions:

    import Plushie.Widget.QrCode, only: [qr_code: 2]

    qr_code("my-id", prop: value)

# `total_size`

```elixir
@spec total_size(widget :: t(), value :: number() | nil) :: t()
```

Total size of the QR code in pixels. Derives cell_size from this.

Accepts `number()`.

# `with_options`

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

Applies keyword options to an existing widget struct.

---

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