@financial-times/o-teaser

中文文档
10.0.4发布于 2026/04/02MITES Module近 30 天下载 4395

Provides styling for teaser elements, which contain information about an article and link through to it

原始使用文档
文档目录10 节
  1. Usage
  2. Development
  3. Markup
  4. Images
  5. Supported elements
  6. Sass
  7. Themes
  8. Migration guide
  9. Contact
  10. Licence

o-teaser

This component is for displaying teasers which link through to articles.

Usage

Check out how to include Origami components in your project to get started with o-teaser.

Development

Install the Origami build tools to build and run demos

Markup

The basic markup structure for a teaser will look something like this:

<div class="o-teaser o-teaser--small">
    <div class="o-teaser__content">
        <a href="#" class="o-teaser__tag">World</a>
        <h2 class="o-teaser__heading">
            <a href="#">Japan sells negative yield 10-year bonds</a>
        </h2>
        <div class="o-teaser__timestamp">
            <time
                data-o-component="o-date"
                class="o-teaser__timestamp-date"
                datetime="2016-02-29T12:35:48Z"
                >2016-02-29T12:35:48Z</time
            >
        </div>
    </div>
</div>

Optionally include the o-date component within your project to render a formatted date within the timestamp element o-teaser__timestamp. This is required to render relative timestamps e.g. "1hr ago".

Teasers support a wide array of elements and can be customised using several themes and should be used as required. For a full list of examples including example markup, see o-teaser in the Registry.

Images

To add an image to a teaser, you should use the following markup structure:

<div class="o-teaser__image-container">
    <img src="{image-src}" class="o-teaser__image" alt="{alt text}" />
</div>

To support lazy-loading of images you can use the o-teaser__image-placeholder element, as below:

<div class="o-teaser__image-container">
    <div class="o-teaser__image-placeholder">
        <img src="{image-src}" class="o-teaser__image" alt="{alt text}" />
    </div>
</div>

Supported elements

The following elements are supported by default:

.o-teaser__tag              # Small coloured tag at the top of the teaser
.o-teaser__tag-suffix       # Small coloured content to come after the tag, such as timestamp or duration
.o-teaser__tag-prefix       # A container for content before the tag
.o-teaser__heading          # Main heading of the teaser
.o-teaser__standfirst       # A short piece of content
.o-teaser__image-container  # Wrapper element for an image
.o-teaser__image            # An image for the teaser
.o-teaser__headshot         # Author's headshot image
.o-teaser__timestamp        # A styled timestamp for the teaser
.o-teaser__related          # A list of related content links
.o-teaser__related-item     # A single item of a related content list

Sass

To include styles for all teasers call oTeaser:

@import '@financial-times/o-teaser/main';

@include oTeaser();

Teasers are made up of various elements (e.g. heading, standfirst, timestamp) and a series of themes (e.g. small, large, video). Pass a list of elements and themes in an options $opts argument to include only the styles you need:

@include oTeaser(
    $opts: (
        'elements': (
            'default',
            'images',
        ),
        'themes': (
            'small',
            'large',
            'video',
        ),
    )
);

Elements are specified via groups, they include:

  • default - all basic text elements, including: heading, standfirst, meta, and tag.
  • images - all image element styles
  • promoted - promoted by and paid post element styles
  • related-items - styling for the related items elements
  • timestamp - styles for the timestamp and live post styles

Themes include:

  • small - styling for small teasers
  • large - styling for large teasers
  • standard - outputs the opinion and inverse themes
  • video - outputs the video teaser styles
  • audio - outputs the audio teaser styles
  • top-stories - outputs all top stories teaser styles and variations
  • hero - outputs all hero teaser styles and variations

Themes

o-teaser has a selection of themes to help highlight content and provide a diverse layout. Themes are separated into 3 types of layout, each with their own modifiers to add different variations on the styles.

Small teasers

Uses the o-teaser--small modifier.

Additional modifiers:

  • stacked: moves the image to the top of the teaser
  • opinion: changes the tag colour to blue
  • live: change background to red and position of elements to make the teaser stand out
  • post: set liveblog post styles

Large teasers

Uses the o-teaser--large modifier.

Additional modifiers:

  • opinion: adds a blue background
  • highlight: adds a claret background

Hero teasers

Uses the o-teaser--hero modifier.

View example on Storybook

Additional modifiers:

  • centred: centres the image and text
  • opinion: adds a blue background
  • highlight: adds a claret background
  • stretched: makes the teaser take up the full height of the available space and anchors the standout and timestamp content to the bottom of the teaser.

Video teasers

Uses the o-teaser--video modifier.

View example on Storybook

Video teasers

Uses the o-teaser--audio modifier.

Migration guide

StateMajor VersionLast Minor ReleaseMigration guide
⚠ maintained8N/Amigrate to v8
╳ deprecated77.2.1migrate to v7
╳ deprecated66.4migrate to v6
╳ deprecated55.2migrate to v5
╳ deprecated44.0migrate to v4
╳ deprecated33.5migrate to v3
╳ deprecated22.5migrate to v2
╳ deprecated11.9-

Contact

If you have any questions or comments about this component, or need help using it, please either raise an issue, visit #origami-support or email Origami Support.


Licence

This software is published by the Financial Times under the MIT licence.

版本与发布记录

@financial-times/o-teaser 共发布 76 个版本,首次发布于 2019/02/13;过去 12 个月发布了 7 个版本。

版本发布日期距今
10.0.4latest2026/04/027 个月前
10.0.32026/03/237 个月前
10.0.12026/03/118 个月前
10.0.02026/02/198 个月前
9.1.32026/02/069 个月前
9.1.22025/12/0311 个月前

其他发布通道:prerelease → 6.0.0-beta.0,tag--v5.2.4 → 5.2.4。

关于 @financial-times/o-teaser 的常见问题

@financial-times/o-teaser 是什么?

Provides styling for teaser elements, which contain information about an article and link through to it

如何安装 @financial-times/o-teaser?

在项目目录运行 npm install @financial-times/o-teaser,或使用 pnpm add / yarn add / bun add。它还需要宿主项目提供 peer 依赖:@financial-times/o-labels(^7.0.0 || ^8.0.0)、@financial-times/o-private-foundation(^1.5.0)。npm 7 及以上与 pnpm 8 及以上默认会自动安装必需的 peer 依赖,Yarn 需要手动安装。

@financial-times/o-teaser 支持 TypeScript 吗?

该包的 package.json 没有声明类型入口。需要类型提示时,可以在 npm 上查找社区维护的 @types/financial-times__o-teaser 是否存在。

@financial-times/o-teaser 支持 ESM 还是 CommonJS?

以 ES Module 形式发布,推荐使用 import 引入。在 CommonJS 项目中,Node.js 20.19+ / 22.12+ 可以直接 require() 不含顶层 await 的 ES Module,更早的版本需要改用动态 import()。

@financial-times/o-teaser 可以商用吗?

@financial-times/o-teaser 使用 MIT 许可。宽松许可:允许商业使用、修改和再分发,通常只需在分发时保留原版权与许可声明。以上为概括,不构成法律意见,请以许可原文为准。

@financial-times/o-teaser 的下载量有多少?

根据 npm 官方下载统计,@financial-times/o-teaser 在 2026/10/15 – 2026/11/13 这 30 天内被下载 4,395 次,日均约 147 次。下载量会把 CI 构建、镜像同步和作为其他包依赖的安装一并计入,适合横向比较热度,不能直接等同于使用人数。

@financial-times/o-teaser 还在维护吗?

最新版本 10.0.4 发布于 2026/04/02(7 个月前);至今共发布 76 个版本,其中过去 12 个月发布了 7 个;首次发布于 2019/02/13。发布频率只是参考信号:功能稳定的工具可能很少需要更新,建议结合源码仓库的 issue 和提交记录判断。