Teaser Warning Review
Teasers are used to attract interest towards linked content with an image or icon, heading, and description.
Typically Teasers are used to promote news articles or other releated content. A Teaser may have a single destination (set with the `url` attribute) and the whole are of the component is clickable, or it may have one or more links in the link slot. When multiple Teasers are presented next to each other, it is recommended to use Duet Grid with grid-template="teaser".
Examples #
Properties #
| Property | Attribute | Description | Type | Default |
|---|---|---|---|---|
description | description | Description text shown below the heading. | string | undefined |
heading | heading | The heading text. | string | undefined |
headingLevel | heading-level | The actual heading level used in the HTML markup. | "h1" | "h2" | "h3" | "h4" | "h5" | "h6" | "h3" |
headingVisualLevel | heading-visual-level | Controls the visual size of the heading. Headings longer than 60 characters always use "h5" visually, regardless of this setting. | "h3" | "h5" | "h3" |
icon | icon | Icon to display when no image is set. Not used if the image property is given. | string | undefined |
iconBackground | icon-background | Background color for the icon | string | "color-background-accent-secondary" |
iconColor | icon-color | Color for the icon | string | "color-foreground-accent-secondary" |
image | image | Image URL. If provided, the icon property is ignored. | string | undefined |
imageAlt | image-alt | Alt attribute text for the image. If not provided, image is assigned presentation role. | string | undefined |
imagePriority | image-priority | Make the image load with higher or lower priority. Value "high" sets the img's attributes fetchpriority and loading to "high" and "eager", while value "low" sets those attributes to "low" and "lazy" | "high" | "low" | undefined |
meta | meta | Meta text (date, category, etc.). Placed after the heading in source order, but rendered visually above it. | string | undefined |
sources | sources | Array of sources for responsive images. Sources have the properties of | DuetSource[] | string | undefined |
theme | theme | Theme. | "" | "default" | "turva" | "" |
url | url | A destination to link to, rendered in the href attribute of a link. Makes the whole teaser act as a link and disables the links slot. | string | undefined |
Methods #
setFocus(options?: FocusOptions) => Promise<void> #
Sets focus on underlying a element.
Available only when url attribute is used.
Use this method instead of the native focus().
Parameters #
| Name | Type | Description |
|---|---|---|
options | FocusOptions |
Returns #
Type: Promise<void>
Slots #
| Slot | Description |
|---|---|
"links" | Slot for links or buttons related to the teaser. Only default duet-link and plain duet-button components should be used in this slot. Not rendered when the url property is set. |
Usage #
This section includes guidelines for designers and developers about the usage of this component in different contexts.
When to use #
- When you want to draw attention to a piece of linked content with an image or icon, heading and short description.
- Especially suitable for situations where you have multiple Teasers together, e.g. news article recommendations, presented with
<duet-grid grid-template="teaser">
When not to use #
- When you need to have longer description - the Teaser is ment for very concise and quick to scan, longer content is in the linked page
- When the constraints of the Teaser otherwise don't fit you use case - it is intentionally quite strict. You may consider e.g. the Banner.
Accessibility #
- The heading content is provided via the
headingslot and rendered in light DOM, so it remains part of the document for search engines and assistive technology. - When the
urlproperty is set, the whole component becomes a single link and thelinksslot is not rendered, to avoid nesting interactive elements.
Integration
For integration, event and theming guidelines, please see Using Components. This documentation explains how to implement and use Duet’s components across different technologies like Angular, React or Vanilla JavaScript.
Tutorials
Follow these practical tutorials to learn how to build simple page layouts using Duet’s CSS Framework, Web Components and other features:
Building Layouts
TutorialsUsing CLI Tools
TutorialsCreating Custom Patterns
TutorialsServer Side Rendering
TutorialsSharing Prototypes
TutorialsUsage With Markdown
Troubleshooting
If you experience any issues while using a component, please head over to the Support page for more guidelines and help.