﻿# nf-text-overflow {#text-overflow}

Multiline text folding with rich slots, responsive measurement and expand/collapse labels in eight languages.

Import the components below; see the package README for standalone installation.

## Examples {#examples}

### Basic usage {#example-1}

### Basic usage
```vue
<script setup>
import { ref } from 'vue'
import { NfConfigProvider, NfTextOverflow } from '@94ai-plus/common-ui'
const content = 'Vue 3 and Element Plus provide reusable components. '.repeat(20)
const expanded = ref(false)
</script>

<template>
  <NfConfigProvider theme="chalk" locale="zh-CN">
    <NfTextOverflow :content="content" :rows="2" :row-height="22" style="max-width:420px" @click-action="event => expanded = event.expanded" />
    <output>expanded: {{ expanded }}</output>
  </NfConfigProvider>
</template>
```

### More examples 2 {#example-2}

### More examples 2
```vue
<script setup>
import { NfConfigProvider, NfTextOverflow } from '@94ai-plus/common-ui'
</script>

<template>
  <NfConfigProvider theme="chalk" locale="zh-CN">
    <NfTextOverflow :rows="2" expand-text="Read more" collapse-text="Read less" style="max-width:320px">
      <p style="margin:0"><strong>Rich content: </strong><span v-for="i in 20" :key="i">Section {{ i }}. </span><a href="https://vuejs.org/" target="_blank" rel="noopener noreferrer">Vue documentation</a></p>
    </NfTextOverflow>
  </NfConfigProvider>
</template>
```

## Props {#props}

Text props follow the library language when omitted; defaults below use this language.

| Parameter | Description | Type | Options | Default |
| --- | --- | --- | --- | --- |
| `rows` | Number of lines when collapsed. | `number \| string` | — | `1` |
| `row-height` | Line height in pixels. | `number \| string` | — | `20` |
| `content` | Text to display; the default slot takes precedence. | `string` | — | `''` |
| `expand-text` | Customize the “Expand” text. | `string` | — | `Expand` |
| `collapse-text` | Customize the “Collapse” text. | `string` | — | `Collapse` |

## Events {#events}

| Event | Description | Payload |
| --- | --- | --- |
| `click-action` | Fires on expand/collapse; includes the original mouse event and expanded state. | `({ event: MouseEvent, expanded: boolean })` |

## Slots {#slots}

| Parameter | Description | Payload |
| --- | --- | --- |
| `default` | Custom text or rich content, taking precedence over content. | — |

## Methods {#methods}

| Name | Type | Description |
| --- | --- | --- |
| `init()` | `void` | Schedule a new overflow measurement. |

## Migration notes {#migration}

The full text DOM is retained and clipped by height rather than truncating strings. No HTML is injected. Content, width and font changes trigger measurement; the toggle is keyboard accessible.
