# Clamped text

- Entry point: `@koobiq/components/clamped-text`
- NgModule: `KbqClampedTextModule`
- API: https://koobiq.io/api/clamped-text.md
- Page: https://koobiq.io/en/components/clamped-text/overview

The **Clamped Text** component helps display long text neatly. When collapsed, it shows only a specified number of lines; when expanded, it reveals the full text.

[**Example: Clamped-text overview** (`clamped-text-overview`)](https://koobiq.io/examples/clamped-text-overview.md)

## Number of lines

By default, text is truncated after 5 lines. The `rows` attribute controls how many lines are shown in the collapsed state:

```html
<kbq-clamped-text [rows]="3">
    In a distributed denial-of-service attack (DDoS attack), the incoming traffic flooding the victim originates from
    many different sources. More sophisticated strategies are required to mitigate this type of attack; simply
    attempting to block a single source is insufficient as there are multiple sources.
</kbq-clamped-text>
```

## A single hidden line is always shown

If the hidden portion contains only one line, the component displays it immediately. The "Expand" button does not appear because the text already takes up the same height as the collapsed state with the button.

## External state control

The collapsed state can be driven from outside: the parent sets it, and gets a new value back when the user operates the toggle.

[**Example: Clamped-text external state** (`clamped-text-external-state`)](https://koobiq.io/examples/clamped-text-external-state.md)

A user action is the only thing that travels back — neither the component's own measurement nor a value the parent wrote itself. That makes the state safe to keep in a route query parameter: a page load will not overwrite the parameter.
