bpk-component-text

8.1.2 • Public • Published

bpk-component-text

Backpack text component.

Installation

npm install bpk-component-text --save-dev

Usage

import React from 'react';
import BpkText, { TEXT_STYLES } from 'bpk-component-text';

export default () => (
  <BpkText tagName="h1" textStyle={TEXT_STYLES.subheading}>My heading</BpkText>
  <BpkText tagName="p">My paragraph</BpkText>
  <BpkText tagName="p" textStyle={TEXT_STYLES.bodyLongform}>My callout paragraph</BpkText>
);

When using the same style in many places repeating the textStyle and tagName props can become tedious in this case you can use withDefaultProps from bpk-react-utils.

import React from 'react';
import BpkText from 'bpk-component-text';
import { withDefaultProps } from 'bpk-react-utils';

const LargeParagraph = withDefaultProps(BpkText, { textStyle: 'bodyLongform', tagName: 'p' });
const TinySpan = withDefaultProps(BpkText, { textStyle: 'caption', tagName: 'span' });

export default () => (
  <div>
    <LargeParagraph>
      Lorem ipsum dolor sit amet, consectetur adipiscing elit.
      Pellentesque imperdiet lobortis tellus, non rhoncus erat tincidunt id.
      Pellentesque consectetur, dolor nec vulputate vehicula, ex metus mattis ante,
      non dictum mi ante eu arcu.
    </LargeParagraph>
    <LargeParagraph>
        Lorem ipsum dolor sit amet, consectetur adipiscing elit.
        Pellentesque imperdiet lobortis tellus, non rhoncus erat tincidunt id.
        Pellentesque consectetur, dolor nec vulputate vehicula, ex metus mattis ante,
        non dictum mi ante eu arcu.
    </LargeParagraph>
    <TinySpan>
      Side effects of Backpack include euphoria, happiness, and increased develpoment velocity.
    </TinySpan>
  </div>
);

Heading textStyle should not be confused with heading tagName that provide structure for SEO and Accessibility. The weight which is normally applied using tagName will be overwritten by the weight defined in the textStyle.

import React from 'react';
import BpkText, { TEXT_STYLES } from 'bpk-component-text';

export default () => (
  <BpkText tagName="h1" textStyle={TEXT_STYLES.heading1}>My heading</BpkText>
  <BpkText tagName="h2" textStyle={TEXT_STYLES.subheading}>My subhheading</BpkText>
);

Props

Property PropType Required Default Value
children - true -
textStyle oneOf(TEXT_STYLES.caption, TEXT_STYLES.footnote, TEXT_STYLES.label1, TEXT_STYLES.label2, TEXT_STYLES.label3, TEXT_STYLES.bodyDefault, TEXT_STYLES.bodyLongform, TEXT_STYLES.subheading, TEXT_STYLES.heading1, TEXT_STYLES.heading2, TEXT_STYLES.heading3, TEXT_STYLES.heading4, TEXT_STYLES.heading5, TEXT_STYLES.hero1, TEXT_STYLES.hero2, TEXT_STYLES.hero3, TEXT_STYLES.hero4, TEXT_STYLES.hero5, TEXT_STYLES.xs, TEXT_STYLES.sm, TEXT_STYLES.base, TEXT_STYLES.lg, TEXT_STYLES.xl, TEXT_STYLES.xxl, TEXT_STYLES.xxxl, TEXT_STYLES.xxxxl, TEXT_STYLES.xxxxxl) false TEXT_STYLES.base
tagName 'span', 'p', 'text', 'h1', 'h2', 'h3', 'h4', 'h5', 'h6' false 'span'
className string false null
bold (deprecated, use a different textStyle to achieve the desired weight) bool false null
weight (deprecated, use a different textStyle to achieve the desired weight) oneOf(WEIGHT_STYLES.regular, WEIGHT_STYLES.bold, WEIGHT_STYLES.black) false null

Versions

Current Tags

VersionDownloads (Last 7 Days)Tag
8.1.22latest
3.0.32-css.00css
2.0.1-alpha.270canary

Version History

VersionDownloads (Last 7 Days)Published
8.1.22
8.1.13
8.1.00
8.0.60
8.0.50
8.0.40
8.0.30
8.0.20
8.0.16
8.0.00
7.0.80
7.0.70
7.0.60
7.0.50
7.0.40
7.0.30
7.0.20
7.0.10
7.0.00
6.2.00
6.1.50
6.1.41
6.1.30
6.1.20
6.1.10
6.1.00
6.0.30
6.0.21
6.0.10
6.0.00
5.1.00
5.0.20
5.0.10
5.0.00
4.0.240
4.0.230
4.0.221
4.0.210
4.0.200
4.0.190
4.0.180
4.0.170
4.0.160
4.0.150
4.0.140
4.0.131
4.0.120
4.0.110
4.0.100
4.0.94
4.0.80
4.0.70
4.0.60
4.0.51
4.0.40
4.0.30
4.0.20
4.0.10
4.0.00
3.2.71,014
3.2.50
3.2.40
3.2.30
3.2.20
3.2.10
3.2.00
3.1.520
3.1.510
3.1.500
3.1.490
3.1.480
3.1.470
3.1.460
3.1.450
3.1.440
3.1.430
3.1.420
3.1.410
3.1.400
3.1.390
3.1.380
3.1.370
3.1.360
3.1.350
3.1.340
3.1.330
3.1.320
3.1.310
3.1.300
3.1.290
3.1.280
3.1.270
3.1.260
3.1.250
3.1.240
3.1.230
3.1.220
3.1.210
3.1.200
3.1.190
3.1.180
3.1.170
3.1.160
3.1.150
3.1.140
3.1.130
3.1.120
3.1.110
3.1.100
3.1.90
3.1.80
3.1.60
3.1.50
3.1.40
3.1.30
3.1.20
3.1.10
3.1.00
3.0.32-css.00
3.0.320
3.0.31-css.00
3.0.310
3.0.30-css.00
3.0.300
3.0.29-css.00
3.0.290
3.0.28-css.00
3.0.280
3.0.27-css.00
3.0.270
3.0.26-css.00
3.0.265
3.0.25-css.00
3.0.250
3.0.24-css.00
3.0.240
3.0.23-css.00
3.0.230
3.0.22-css.00
3.0.220
3.0.21-css.00
3.0.210
3.0.20-css.00
3.0.200
3.0.19-css.00
3.0.190
3.0.18-css.00
3.0.180
3.0.17-css.00
3.0.170
3.0.16-css.00
3.0.160
3.0.15-css.00
3.0.150
3.0.14-css.00
3.0.140
3.0.13-css.00
3.0.130
3.0.12-css.00
3.0.120
3.0.11-css.00
3.0.110
3.0.100
3.0.90
3.0.8-css.00
3.0.80
3.0.7-css.00
3.0.70
3.0.6-css.00
3.0.60
3.0.5-css.00
3.0.50
3.0.4-css.00
3.0.40
3.0.3-css.00
3.0.30
3.0.2-css.00
3.0.20
3.0.1-css.00
3.0.10
3.0.0-css.00
3.0.00
2.0.31-css.00
2.0.310
2.0.30-css.00
2.0.300
2.0.290
2.0.280
2.0.27-css.00
2.0.270
2.0.26-css.00
2.0.260
2.0.25-css.00
2.0.250
2.0.24-css.00
2.0.240
2.0.23-css.00
2.0.230
2.0.22-css.00
2.0.220
2.0.21-css.00
2.0.210
2.0.20-css.00
2.0.200
2.0.19-css.00
2.0.190
2.0.18-css.00
2.0.180
2.0.17-css.00
2.0.172
2.0.16-css.00
2.0.160
2.0.15-css.00
2.0.150
2.0.13-css.00
2.0.130
2.0.12-css.00
2.0.120
2.0.11-css.00
2.0.110
2.0.10-css.00
2.0.100
2.0.9-css.00
2.0.90
2.0.8-css.00
2.0.80
2.0.7-css.00
2.0.70
2.0.6-css.00
2.0.60
2.0.50
2.0.40
2.0.30
2.0.20
2.0.10
2.0.1-alpha.270
2.0.00
1.2.20
1.2.2-alpha.20
1.2.10
1.2.00
1.1.290
1.1.280
1.1.270
1.1.260
1.1.250
1.1.240
1.1.230
1.1.220
1.1.210
1.1.200
1.1.20-alpha.10
1.1.190
1.1.180
1.1.170
1.1.160
1.1.150
1.1.140
1.1.130
1.1.120
1.1.110
1.1.100
1.1.90
1.1.80
1.1.70
1.1.60
1.1.5-alpha.10
1.1.40
1.1.2-alpha.130
1.1.30
1.1.20
1.1.2-alpha.90
1.1.10
1.1.00
1.0.132-alpha.40
1.0.1310
1.0.131-alpha.90
1.0.1300
1.0.1290
1.0.1280
1.0.1270
1.0.1260
1.0.1250
1.0.125-alpha.10
1.0.1240
1.0.1230
1.0.1220
1.0.1210
1.0.1200
1.0.120-alpha.10
1.0.1190
1.0.119-alpha.90
1.0.1180
1.0.117-alpha.190
1.0.1170
1.0.1160
1.0.1150
1.0.1140
1.0.1130
1.0.1120
1.0.1110
1.0.1100
1.0.110-alpha.10
1.0.1090
1.0.1080
1.0.108-alpha.10
1.0.1070
1.0.1060
1.0.1050
1.0.1040
1.0.1030
1.0.1020
1.0.1010
1.0.1000
1.0.100-alpha.50
1.0.990
1.0.980
1.0.970
1.0.960
1.0.950
1.0.940
1.0.930
1.0.93-alpha.30
1.0.920
1.0.92-beta.10
1.0.910
1.0.900
1.0.890
1.0.880
1.0.870
1.0.860
1.0.850
1.0.84-alpha.120
1.0.830
1.0.820
1.0.810
1.0.800
1.0.80-alpha.20
1.0.790
1.0.780
1.0.770
1.0.760
1.0.750
1.0.740
1.0.730
1.0.720
1.0.710
1.0.700
1.0.690
1.0.680
1.0.670
1.0.660
1.0.650
1.0.640
1.0.630
1.0.620
1.0.610
1.0.600
1.0.590
1.0.580
1.0.570
1.0.560
1.0.550
1.0.540
1.0.530
1.0.520
1.0.510
1.0.500
1.0.490
1.0.480
1.0.470
1.0.460
1.0.450
1.0.440
1.0.430
1.0.420
1.0.410
1.0.400
1.0.390
1.0.380
1.0.370
1.0.360
1.0.350
1.0.340
1.0.330
1.0.320
1.0.310
1.0.300
1.0.290
1.0.280
1.0.270
1.0.260
1.0.250
1.0.240
1.0.231
1.0.220
1.0.210
1.0.200
1.0.190
1.0.180
1.0.170
1.0.160
1.0.150
1.0.140
1.0.120
1.0.100
1.0.90
1.0.80
1.0.70
1.0.60
1.0.50
1.0.40
1.0.30
1.0.20
1.0.10
1.0.00

Package Sidebar

Install

npm i bpk-component-text

Weekly Downloads

1,042

Version

8.1.2

License

Apache-2.0

Unpacked Size

41.7 kB

Total Files

10

Last publish

Collaborators

  • mungodewar
  • anambl
  • skyscanner-koalasquad
  • gert-jan.vercauteren
  • frugoman
  • marianeumayer-skyscanner
  • ojcurt