|
| 1 | +# Sass |
| 2 | + |
| 3 | +> Sass documentation for `@carbon/type` |
| 4 | +
|
| 5 | +## Usage |
| 6 | + |
| 7 | +The `@carbon/type` package enables you to use typography from the IBM Design |
| 8 | +Language, including the type scale and fonts, along with typography design |
| 9 | +tokens from the Carbon Design System. It also comes with opinionated defaults |
| 10 | +for type styles on common elements like `h1`, `h2`, `p`, etc. |
| 11 | + |
| 12 | +You can use this package by writing the following: |
| 13 | + |
| 14 | +```scss |
| 15 | +@use '@carbon/type'; |
| 16 | + |
| 17 | +// Include type reset |
| 18 | +@include type.reset(); |
| 19 | + |
| 20 | +// Include default type styles, targets h1, h2, h3, etc |
| 21 | +@include type.default-type(); |
| 22 | + |
| 23 | +// Include utility classes for type-related properties |
| 24 | +@include type.type-classes(); |
| 25 | + |
| 26 | +.selector { |
| 27 | + // Include a type style |
| 28 | + @include type.style('productive-heading-01'); |
| 29 | +} |
| 30 | +``` |
| 31 | + |
| 32 | +### Type classes |
| 33 | + |
| 34 | +The `type-classes` mixin will output a collection of utility CSS that you can |
| 35 | +use to style a given HTML element with type-related styles. |
| 36 | + |
| 37 | +In particular, you can use the following classes: |
| 38 | + |
| 39 | +| Class | Description | |
| 40 | +| :------------------------- | :-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | |
| 41 | +| `.cds--type-{font-family}` | Set the `font-family` property for the given font. This can include `mono`, `sans`, `sans-condensed`, `sans-arabic`, `sans-devanagari`, `sans-hebrew`, `sans-jp`, `sans-kr`, `sans-thai-looped`, `sans-thai`, `serif` | |
| 42 | +| `.cds--type-{font-weight}` | Set the `font-weight` property | |
| 43 | +| `.cds--type-italic` | Set the `font-style` property to `italic` | |
| 44 | +| `.cds--type-{token}` | Style the HTML element with the given type token | |
| 45 | + |
| 46 | +## API |
| 47 | + |
| 48 | +| Export | Description | Link | !default | |
| 49 | +| :------------------------- | :---------------------------------------------------------------- | :--- | :------- | |
| 50 | +| `@mixin type-classes` | A mixin used to emit utility type classes in CSS | | | |
| 51 | +| `@mixin reset` | A mixin used to emit base styles for the Carbon Design System | | | |
| 52 | +| `@mixin default-type` | A mixin used to emit default styles for typographic HTML elements | | | |
| 53 | +| `@mixin type-style` | A mixin used to emit all declarations for a type token | | | |
| 54 | +| `$label-01` | | | ✅ | |
| 55 | +| `$legal-02` | | | ✅ | |
| 56 | +| `$helper-text-01` | | | ✅ | |
| 57 | +| `$body-short-01` | | | ✅ | |
| 58 | +| `$body-compact-01` | | | ✅ | |
| 59 | +| `$body-long-01` | | | ✅ | |
| 60 | +| `$body-01` | | | ✅ | |
| 61 | +| `$body-short-02` | | | ✅ | |
| 62 | +| `$body-compact-02` | | | ✅ | |
| 63 | +| `$body-long-02` | | | ✅ | |
| 64 | +| `$body-02` | | | ✅ | |
| 65 | +| `$code-01` | | | ✅ | |
| 66 | +| `$code-02` | | | ✅ | |
| 67 | +| `$heading-01` | | | ✅ | |
| 68 | +| `$productive-heading-01` | | | ✅ | |
| 69 | +| `$heading-compact-01` | | | ✅ | |
| 70 | +| `$heading-02` | | | ✅ | |
| 71 | +| `$productive-heading-02` | | | ✅ | |
| 72 | +| `$heading-compact-02` | | | ✅ | |
| 73 | +| `$productive-heading-03` | | | ✅ | |
| 74 | +| `$heading-03` | | | ✅ | |
| 75 | +| `$productive-heading-04` | | | ✅ | |
| 76 | +| `$heading-04` | | | ✅ | |
| 77 | +| `$productive-heading-05` | | | ✅ | |
| 78 | +| `$heading-05` | | | ✅ | |
| 79 | +| `$productive-heading-06` | | | ✅ | |
| 80 | +| `$heading-06` | | | ✅ | |
| 81 | +| `$productive-heading-07` | | | ✅ | |
| 82 | +| `$heading-07` | | | ✅ | |
| 83 | +| `$expressive-heading-01` | | | ✅ | |
| 84 | +| `$expressive-heading-02` | | | ✅ | |
| 85 | +| `$expressive-heading-03` | | | ✅ | |
| 86 | +| `$fluid-heading-03` | | | ✅ | |
| 87 | +| `$expressive-heading-04` | | | ✅ | |
| 88 | +| `$fluid-heading-04` | | | ✅ | |
| 89 | +| `$expressive-heading-05` | | | ✅ | |
| 90 | +| `$fluid-heading-05` | | | ✅ | |
| 91 | +| `$expressive-heading-06` | | | ✅ | |
| 92 | +| `$fluid-heading-06` | | | ✅ | |
| 93 | +| `$expressive-paragraph-01` | | | ✅ | |
| 94 | +| `$fluid-paragraph-01` | | | ✅ | |
| 95 | +| `$quotation-01` | | | ✅ | |
| 96 | +| `$fluid-quotation-01` | | | ✅ | |
| 97 | +| `$quotation-02` | | | ✅ | |
| 98 | +| `$fluid-quotation-02` | | | ✅ | |
| 99 | +| `$display-01` | | | ✅ | |
| 100 | +| `$fluid-display-01` | | | ✅ | |
| 101 | +| `$display-02` | | | ✅ | |
| 102 | +| `$fluid-display-02` | | | ✅ | |
| 103 | +| `$display-03` | | | ✅ | |
| 104 | +| `$fluid-display-03` | | | ✅ | |
| 105 | +| `$display-04` | | | ✅ | |
| 106 | +| `$fluid-display-04` | | | ✅ | |
| 107 | + |
| 108 | +### Configuration |
| 109 | + |
| 110 | +You can configure parts of the `@carbon/type` package with Sass Modules. For |
| 111 | +example, you can change the `$prefix` used by writing the following: |
| 112 | + |
| 113 | +```scss |
| 114 | +@use '@carbon/type' with ( |
| 115 | + $prefix: 'custom-prefix', |
| 116 | +); |
| 117 | +``` |
| 118 | + |
| 119 | +For a full list of options that you can configure, check out the table below. |
| 120 | + |
| 121 | +| Option | Description | Default | |
| 122 | +| :-------- | :---------------------------------------------------------------- | :------ | |
| 123 | +| `$prefix` | The prefix that is used in selectors, CSS Custom Properties, etc. | `'cds'` | |
0 commit comments