A text snippet is used to display a section of text with the ability to show or hide content beyond one line of text.
Text snippets provide a way to show previews of long content while allowing users to expand and read the full text when needed. They help condense screen space by truncating long text blocks such as product descriptions, reviews, or articles. By default, content is displayed in condensed mode with a toggle button to expand or collapse the full text.
When to use
To use text snippet, import DaffTextSnippetComponent
directly into your custom component:
import { DaffTextSnippetComponent } from '@daffodil/design/text-snippet';
@Component({
selector: 'custom-component',
templateUrl: './custom-component.component.html',
imports: [
DaffTextSnippetComponent,
],
})
export class CustomComponent {}
Text snippet supports two ways of providing content.
html
input:<daff-text-snippet [html]="categoryDescription"></daff-text-snippet>
<daff-text-snippet>
Category description
</daff-text-snippet>
Text snippet provides built-in support for assistive technologies:
aria-expanded
attribute, which reflects whether the snippet is currently expanded (true
) or condensed (false
).