@financial-times/o-labels

中文文档
8.0.2发布于 2026/04/02MITES Module零依赖近 30 天下载 6336

Labels for content classification or to emphasise a value. Provides customisation options with the FT colour palette.

原始使用文档
文档目录17 节
  1. Usage
  2. Label Types
  3. Standard Label
  4. Indicator Label
  5. Timestamp Label
  6. Markup
  7. Standard Label Markup
  8. Indicator Label Markup
  9. Timestamp Markup
  10. Sass
  11. Custom Standard Label State
  12. Custom Markup
  13. oLabelsContent
  14. oLabelsIndicatorContent
  15. Migration guide
  16. Contact
  17. Licence

o-labels

Labels for content classification, to emphasise a value, or highlight a status.

Usage

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

Label Types

There are three types of label:

Standard Label

The standard label is used for content classification or to emphasise a value. For example to highlight commercial or premium content for the core brand, or to highlight a service tier in internal products. Custom labels may be created.

Standard Label Sizes

This table outlines the possible standard label sizes.

SizeDescriptionBrand support
bigLabel with increased font size and padding.core, internal, whitelabel
smallLabel with decreased font size and padding.core, internal, whitelabel

Standard Label States

This table outlines the possible standard label states. Custom states may also be created.

StateDescriptionBrand support
content-commercialUsed to identify paid posts or promoted content.core
content-premiumUsed to identify premium content.core
lifecycle-betaUsed to identify a feature that's in beta.core
support-activeUsed to indicate that a component is actively maintained.internal
support-maintainedUsed to indicate that a component is maintained.internal
support-experimentalUsed to indicate that a component is an experimental feature.internal
support-deprecatedUsed to indicate that a component is deprecated.internal
support-deadUsed to indicate that a component is no longer worked on.internal
tier-platinumUsed to indicate a service with a platinum service tier.internal
tier-goldUsed to indicate a service with a gold service tier.internal
tier-silverUsed to indicate a service with a silver service tier.internal
tier-bronzeUsed to indicate a service with a bronze service tier.internal
oxfordA colour based label with no specific meaning specified.internal
tealA colour based label with no specific meaning specified.internal
lemonA colour based label with no specific meaning specified.internal
slateA colour based label with no specific meaning specified.internal
jadeA colour based label with no specific meaning specified.internal
crimsonA colour based label with no specific meaning specified.internal
mandarinA colour based label with no specific meaning specified.internal

Indicator Label

The indicator label is used to show story status with new, updated, and live variants. The indicator label only supports the core brand but internal brand support is under consideration.

Indicator Label Status

This table outlines the possible indicator label statuses:

IndicatorDescriptionBrand support
liveIndicate a story is live.core
closedIndicate a live story is no longer live.core
newIndicate a story is new.core
updatedIndicate a story has been updated.core

E.g. for a live label:

<span class="o-labels-indicator o-labels-indicator--live">
    <span class="o-labels-indicator__status">live</span>
</span>

The live and closed labels also support a more prominent badge variant:

<span
    class="o-labels-indicator o-labels-indicator--live o-labels-indicator--inverse o-labels-indicator--badge"
>
    <span class="o-labels-indicator__status">live</span>
</span>

Timestamp Label

The timestamp label is used to show article status in place of an indicator label when the article is not new, updated, or live. The timestamp label only supports the core brand.

Markup

Standard Label Markup

The most minimal markup for a standard label is as follows:

<span class="o-labels">Label</span>

Standard labels are displayed inline so including the above markup in a paragraph, for example, will make it sit alongside the text.

There are several size modifier classes which can be used to change the general appearance of a standard label:

<span class="o-labels o-labels--big">Big Label</span>
<span class="o-labels o-labels--small">Small Label</span>

Labels can also have one of several states. The available states depend on which brand you are using (there are no states for whitelabel branded components):

The following core brand states are used to categorise content, mostly on FT.com:

<span class="o-labels o-labels--content-commercial">Paid Post</span> (used for
paid post and promoted content)
<span class="o-labels o-labels--content-premium">Premium</span> (used for
premium-only content)

The following state is used to indicate that a feature is in a beta state:

<span class="o-labels o-labels--lifecycle-beta">Beta</span>

The following internal brand states are used to represent the different support levels of Origami components:

<span class="o-labels o-labels--support-active">Active</span>
<span class="o-labels o-labels--support-maintained">Maintained</span>
<span class="o-labels o-labels--support-experimental">Experimental</span>
<span class="o-labels o-labels--support-deprecated">Deprecated</span>
<span class="o-labels o-labels--support-dead">Dead</span>

The following internal brand states are used to represent the FT's service tiers:

<span class="o-labels o-labels--support-platinum">Platinum</span>
<span class="o-labels o-labels--support-gold">Gold</span>
<span class="o-labels o-labels--support-silver">Silver</span>
<span class="o-labels o-labels--support-bronze">Bronze</span>

The internal brand may also use colour palette based states, these do not specify a particular usecase for flexibility:

<span class="o-labels o-labels--oxford">oxford</span>
<span class="o-labels o-labels--teal">teal</span>
<span class="o-labels o-labels--lemon">lemon</span>
<span class="o-labels o-labels--slate">slate</span>
<span class="o-labels o-labels--jade">jade</span>
<span class="o-labels o-labels--crimson">crimson</span>
<span class="o-labels o-labels--mandarin">mandarin</span>

Indicator Label Markup

Indicator labels have one of three statuses:

  • live
  • closed
  • updated
  • new

Use the following markup for a live label:

<span class="o-labels-indicator o-labels-indicator--live">
    <span class="o-labels-indicator__status"> live </span>
</span>

Use the modifier class o-labels-indicator--closed for a closed label:

<span class="o-labels-indicator o-labels-indicator--closed">
    <span class="o-labels-indicator__status"> closed </span>
</span>

For an updated or new label use the associated modifier class, e.g. o-labels-indicator--updated, and add a child element o-labels-indicator__timestamp to show the new/updated time. We recommend using o-date to format the timestamp element.

<span class="o-labels-indicator o-labels-indicator--new">
    <span class="o-labels-indicator__status"> new </span>
    <span class="o-labels-indicator__timestamp">
        <!-- demo `time` element only (the datetime is not 1 hour ago) -->
        <time datetime="2020-07-09T12:52:33+0000" title="July 9 2020 1:52 pm"
            >1 hour ago</time
        >
    </span>
</span>

Indicator labels also support an inverse theme for use on dark backgrounds. To use an inverse theme add the o-labels-indicator--inverse class to your markup.

-<span class="o-labels-indicator o-labels-indicator--live">
+<span class="o-labels-indicator o-labels-indicator--live o-labels-indicator--inverse">
    <span class="o-labels-indicator__status">
        live
    </span>
</span>

Timestamp Markup

To include a timestamp label use the following markup. Note the timestamp label also supports an optional inverse variant for dark background with the o-labels-timestamp--inverse class:

<span class="o-labels-timestamp o-labels-timestamp--inverse">
    <!-- demo `time` element only -->
    <time datetime="2016-02-29T12:35:48Z" title="February 29 2016 12:35 pm"
        >February 29 2016</time
    >
</span>

As with the indicator label, we recommend using o-date to format the timestamp element.

Sass

Output all label styles with the oLabels mixin:

@include oLabels();

Or pass an options map $opts argument to output just the label styles you need. Options include:

  • sizes: a list of standard label sizes to output (see available sizes)
  • states: a list of standard label states to output (see available states))
  • indicators
  • timestamp
    • inverse
@include oLabels(
    $opts: (
        // standard label sizes to output
        // e.g. .o-labels--big
        'sizes': ('big'),
        // standard label states to output
        // e.g. .o-labels--content-commercial
        'states': ('content-commercial', 'content-premium'),
        // indicator label labels to output
        // .o-labels-indicator
        'indicators':
            (
                // indicator label statuses to output
                // .o-labels-indicator--live
                'status': ('live'),
                // whether to output the indicator label inverse style
                // .o-labels-indicator--inverse
                'inverse': true
            ),
        // output the timestamp label label
        // .o-labels-timestamp
        'timestamp':
            (
                // whether to output the timestamp label inverse style
                // .o-labels-timestamp--inverse
                'inverse': true
            ),
    )
);

Custom Standard Label State

Use oLabelsAddState mixin to add a custom label state for the standard label. See the oLabelsAddState SassDoc for more details.

// outputs a class .o-labels--citrus-fruit
@include oLabelsAddState(
    'citrus-fruit',
    (
        background-color: oColorsByName('lemon'),
    )
);

Custom Markup

When it's not possible to use an o-labels CSS class, for example within another Origami component, use:

  • oLabelsContent to output a standard label with a custom class.
  • oLabelsIndicatorContent to output an indicator label with a custom class.
  • oLabelsTimestampContent to output a timestamp label with a custom class.

If it is possible to use o-labels classes we recommend oLabels and oLabelsAddStates instead. Using these will help reduce the size of your CSS bundle where multiple labels are used.

oLabelsContent

oLabelsContent accepts an $opts argument which is a map of options. To output styles required by all labels set "base" to "true". Then set the labels "sizes" and its "state". Any of these options may be output independently.

To output an existing label:

.o-example-my-label {
    @include oLabelsContent(
        $opts: (
            'base': true,
            'size': 'big',
            'state': 'tier-gold',
        )
    );
}

To output a custom label:

.o-example-my-custom-label {
    @include oLabelsContent(
        $opts: (
            'base': true,
            'size': 'big',
            'state': (
                'background-color': oColorsByName('lemon'),
            ),
        )
    );
}

oLabelsIndicatorContent

As styles for the indicator label apply to multiple html elements, the oLabelsIndicatorContent accepts an $opts argument to output styles for each element separately.

// equivalent to .o-labels-indicator
.my-indicator-label {
    @include oLabelsIndicatorContent(
        $opts: (
            'block': true,
        )
    );
}
// equivalent to .o-labels-indicator--live
.my-indicator-label--live {
    @include oLabelsIndicatorContent(
        $opts: (
            'block': true,
            'modifier': 'live',
        )
    );
}
// equivalent to .o-labels-indicator__status
.my-indicator-label__status {
    @include oLabelsIndicatorContent(
        $opts: (
            'element': 'status',
        )
    );
}
// equivalent to .o-labels-indicator__timestamp
.my-indicator-label__timestamp {
    @include oLabelsIndicatorContent(
        $opts: (
            'element': 'timestamp',
        )
    );
}

Migration guide

StateMajor VersionLast Minor ReleaseMigration guide
⚠ maintained7N/Amigrate to v7
╳ deprecated66.5migrate to v6
╳ deprecated55.2migrate to v5
╳ deprecated4N/Amigrate to v4
╳ deprecated33.1.1migrate to v3
╳ deprecated22.1.0N/A
╳ deprecated11.0.6N/A

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-labels 共发布 56 个版本,首次发布于 2019/02/13;过去 12 个月发布了 3 个版本。

版本发布日期距今
8.0.2latest2026/04/027 个月前
8.0.12026/02/268 个月前
8.0.02026/02/069 个月前
7.1.22025/10/291 年前
7.1.02025/10/221.1 年前
7.0.32025/09/181.2 年前

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

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

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

Labels for content classification or to emphasise a value. Provides customisation options with the FT colour palette.

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

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

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

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

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

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

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

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

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

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

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

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