# `Alaja.Structures.ChunkText`
[🔗](https://github.com/Lorenzo-SF/alaja/blob/2.1.0/lib/alaja/structures/chunk_text.ex#L1)

Minimal text chunk with formatting.

Represents a text fragment with its color and effects information.
This is the basic composition unit for formatted text rendering.

## Examples

    iex> ChunkText.new("Hello world")
    %ChunkText{text: "Hello world", color: nil, bg_color: nil, effects: nil}

    iex> ChunkText.new("Hello", color: :red, effects: [:bold])
    %ChunkText{text: "Hello", color: %ColorInfo{...}, effects: %EffectInfo{...}}

# `t`

```elixir
@type t() :: %Alaja.Structures.ChunkText{
  bg_color: Pote.ColorInfo.t() | nil,
  color: Pote.ColorInfo.t() | nil,
  effects: Alaja.Structures.EffectInfo.t() | nil,
  text: String.t()
}
```

# `combine`

```elixir
@spec combine(any(), any()) :: any()
```

Combines two ChunkTexts (useful for concatenating formatted text).

The second chunk's properties take precedence over the first's.

## Examples

    iex> c1 = ChunkText.new("Hello", color: :red)
    iex> c2 = ChunkText.new(" world", color: :green)
    iex> ChunkText.combine(c1, c2)
    %ChunkText{text: "Hello world", color: %ColorInfo{...}}

# `new`

```elixir
@spec new(
  String.t(),
  keyword()
) :: t()
```

Creates a new ChunkText.

## Parameters

- `text` - The text to display
- `opts` - Optional options:
  - `:color` - ColorInfo or convertible value (atom, hex, rgb, etc.)
  - `:bg_color` - Background ColorInfo or convertible value
  - `:effects` - EffectInfo or list of effects

## Examples

    iex> ChunkText.new("Hello")
    %ChunkText{text: "Hello"}

    iex> ChunkText.new("Hello", color: :red)
    %ChunkText{text: "Hello", color: %ColorInfo{...}}

    iex> ChunkText.new("Hello", color: "#FF0000", effects: [:bold, :underline])
    %ChunkText{text: "Hello", color: %ColorInfo{...}, effects: %EffectInfo{...}}

# `render`

```elixir
@spec render(t()) :: String.t()
```

Renders the ChunkText with ANSI codes.

Produces true-color (24-bit) ANSI sequences with effects.
Always resets formatting after the text.

## Examples

    iex> ChunkText.render(ChunkText.new("Hello", color: :red, effects: [:bold]))
    "\e[38;2;255;0;0m\e[1mHello\e[0m"

---

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